From 5a661fdaccf71d940ae13cf1d3712702a1fd3a26 Mon Sep 17 00:00:00 2001 From: Chris Causer Date: Wed, 14 Dec 2011 13:05:06 +0000 Subject: [PATCH 1/2] Add tests for escaped characters in title --- test/test_app.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test_app.rb b/test/test_app.rb index 03c3d023..2d065249 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -85,6 +85,20 @@ context "Frontend" do assert_equal 'def', page.version.message end + test "creates pages with escaped characters in title" do + post "/create", :content => 'abc', :page => 'Title with spaces', + :format => 'markdown', :message => 'foo' + assert_equal 'http://example.org/Title-with-spaces', last_response.headers['Location'] + get "/Title-with-spaces" + assert_match /abc/, last_response.body + + post "/create", :content => 'ghi', :page => 'Title/with/slashes', + :format => 'markdown', :message => 'bar' + assert_equal 'http://example.org/Title-with-slashes', last_response.headers['Location'] + get "/Title-with-slashes" + assert_match /ghi/, last_response.body + end + test "guards against creation of existing page" do name = "A" post "/create", :content => 'abc', :page => name, From d389390523cb1118af11fe247403e1723536b9f7 Mon Sep 17 00:00:00 2001 From: Chris Causer Date: Wed, 14 Dec 2011 13:10:44 +0000 Subject: [PATCH 2/2] Escape names on page create redirect --- lib/gollum/frontend/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index f14eb4d0..bcd057ce 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -77,7 +77,7 @@ module Precious begin wiki.write_page(name, format, params[:content], commit_message) - redirect "/#{CGI.escape(name)}" + redirect "/#{CGI.escape(Gollum::Page.cname(name))}" rescue Gollum::DuplicatePageError => e @message = "Duplicate page: #{e.message}" mustache :error