From 20566f8acfd4b060561978adf62c3f23355ca41b Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 25 Aug 2012 18:54:07 -0600 Subject: [PATCH] Fix #484 --- lib/gollum/frontend/app.rb | 4 +++- test/test_app.rb | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 10f21ddb..e7c368f7 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -90,7 +90,9 @@ module Precious redirect File.join(settings.wiki_options[:base_path].to_s, 'Home') end + # Removes all slashes from the start of string. def clean_url url + return url if url.nil? url.gsub('%2F','/').gsub(/^\/+/,'') end @@ -146,7 +148,7 @@ module Precious end post '/edit/*' do - path = sanitize_empty_params(params[:path]) + path = '/' + clean_url(sanitize_empty_params(params[:path])).to_s page_name = CGI.unescape(params[:page]) wiki = wiki_new page = wiki.paged(page_name, path, exact = true) diff --git a/test/test_app.rb b/test/test_app.rb index c18c715f..18f158e9 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -50,6 +50,14 @@ context "Frontend" do assert_not_equal page_1.version.sha, page_2.version.sha end + test "edit page with slash" do + page_1 = @wiki.page('A') + post "/edit/A", :content => 'abc', :page => 'A', :path => '/////', + :format => page_1.format, :message => 'def' + follow_redirect! + assert last_response.ok? + end + test "edits page header footer and sidebar" do commits = @wiki.repo.commits('master').size page_1 = @wiki.page('A')