From 8b14617aea0e178e5688e790ea5a781ff76b493c Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Tue, 29 Mar 2005 06:10:01 +0000 Subject: [PATCH] Removed explicit conversions of URL elements - routing does that, and it was therefore done twice - wrong --- app/controllers/application.rb | 2 +- app/controllers/wiki_controller.rb | 4 ++-- app/views/wiki/new.rhtml | 2 +- test/functional/wiki_controller_test.rb | 12 ++++++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 47a267e7..abf82902 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -91,7 +91,7 @@ class ApplicationController < ActionController::Base def redirect_show(page_name = @page_name, web = @web_name) redirect_to :web => web, :controller => 'wiki', :action => 'show', - :id => CGI.escape(page_name || 'HomePage') + :id => (page_name || 'HomePage') end @@REMEMBER_NOT = ['locked', 'save', 'back', 'file', 'pic', 'import'] diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 29f520ef..e0f13b02 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -202,14 +202,14 @@ class WikiController < ApplicationController logger.error e if in_a_web? redirect_to :web => @web_name, :action => 'edit', - :action_suffix => "#{CGI.escape(@page_name)}?msg=#{CGI.escape(e.message)}" + :action_suffix => "#{@page_name}?msg=#{e.message}" else raise e end end else if not @page_name.nil? and not @page_name.empty? - redirect_to :web => @web_name, :action => 'new', :id => CGI.escape(@page_name) + redirect_to :web => @web_name, :action => 'new', :id => @page_name else render_text 'Page name is not specified', '404 Not Found' end diff --git a/app/views/wiki/new.rhtml b/app/views/wiki/new.rhtml index 503184d3..e0fa0c2b 100644 --- a/app/views/wiki/new.rhtml +++ b/app/views/wiki/new.rhtml @@ -6,7 +6,7 @@ <%= render("#{@web.markup}_help") if @web %> -<%= form_tag({ :action => 'save', :web => @web.address, :id => CGI.escape(@page_name)}, +<%= form_tag({ :action => 'save', :web => @web.address, :id => @page_name}, {'id' => 'editForm', 'method' => 'post', 'onSubmit' => 'cleanAuthorName();'}) %> diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 4e641b93..c8559118 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -89,6 +89,18 @@ class WikiControllerTest < Test::Unit::TestCase process 'edit', 'web' => 'wiki1', 'id' => 'UnknownPage', 'break_lock' => 'y' assert_redirected_to :action => 'index' end + + def test_edit_page_with_special_symbols + @wiki.write_page('wiki1', 'With : Special /> symbols', + 'This page has special symbols in the name', + Time.now, Author.new('Special', '127.0.0.3')) + + r = process 'edit', 'web' => 'wiki1', 'id' => 'With : Special /> symbols' + assert_success + xml = REXML::Document.new(r.body) + form = REXML::XPath.first(xml, '//form') + assert_equal '/wiki1/save/With+%3A+Special+%2F%3E+symbols', form.attributes['action'] + end def test_export_html