Removed explicit conversions of URL elements - routing does that, and it was therefore done twice - wrong

This commit is contained in:
Alexey Verkhovsky 2005-03-29 06:10:01 +00:00
parent 5e971e00b7
commit 8b14617aea
4 changed files with 16 additions and 4 deletions

View file

@ -91,7 +91,7 @@ class ApplicationController < ActionController::Base
def redirect_show(page_name = @page_name, web = @web_name) def redirect_show(page_name = @page_name, web = @web_name)
redirect_to :web => web, :controller => 'wiki', :action => 'show', redirect_to :web => web, :controller => 'wiki', :action => 'show',
:id => CGI.escape(page_name || 'HomePage') :id => (page_name || 'HomePage')
end end
@@REMEMBER_NOT = ['locked', 'save', 'back', 'file', 'pic', 'import'] @@REMEMBER_NOT = ['locked', 'save', 'back', 'file', 'pic', 'import']

View file

@ -202,14 +202,14 @@ class WikiController < ApplicationController
logger.error e logger.error e
if in_a_web? if in_a_web?
redirect_to :web => @web_name, :action => 'edit', 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 else
raise e raise e
end end
end end
else else
if not @page_name.nil? and not @page_name.empty? 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 else
render_text 'Page name is not specified', '404 Not Found' render_text 'Page name is not specified', '404 Not Found'
end end

View file

@ -6,7 +6,7 @@
<%= render("#{@web.markup}_help") if @web %> <%= 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();'}) {'id' => 'editForm', 'method' => 'post', 'onSubmit' => 'cleanAuthorName();'})
%> %>

View file

@ -90,6 +90,18 @@ class WikiControllerTest < Test::Unit::TestCase
assert_redirected_to :action => 'index' assert_redirected_to :action => 'index'
end 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 def test_export_html
setup_wiki_with_three_pages setup_wiki_with_three_pages