diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c727d0b..288f734 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 89af800..48260cc 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