From 3be2185683479f65e95cba89a419e30375a34df6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 15 Jun 2016 19:04:36 +0000 Subject: [PATCH] Removes the UTF8 checkmark that prevents redirect from back_url. git-svn-id: http://svn.redmine.org/redmine/trunk@15535 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 5 +++++ test/unit/helpers/application_helper_test.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c727d0be5..288f734f2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1109,6 +1109,11 @@ module ApplicationHelper url = params[:back_url] if url.nil? && referer = request.env['HTTP_REFERER'] url = CGI.unescape(referer.to_s) + # URLs that contains the utf8=[checkmark] parameter added by Rails are + # parsed as invalid by URI.parse so the redirect to the back URL would + # not be accepted (ApplicationController#validate_back_url would return + # false) + url.gsub!(/(\?|&)utf8=\u2713&?/, '\1') end url end diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 89af800be..48260ccf7 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -1538,4 +1538,9 @@ RAW assert_equal "#{ja} #{ja}...", result assert !result.html_safe? end + + def test_back_url_should_remove_utf8_checkmark_from_referer + stubs(:request).returns(stub(:env => {'HTTP_REFERER' => "/path?utf8=\u2713&foo=bar"})) + assert_equal "/path?foo=bar", back_url + end end -- 2.39.5