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
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