Project

General

Profile

Feature #40190 » 0001-Stop-appending-the-utf8-checkmark-parameter-to-form-.patch

Go MAEDA, 2024-02-04 06:55

View differences:

app/controllers/application_controller.rb
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
config/application.rb
config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
# Stop appending "utf8=✓" to form URLs
config.action_view.default_enforce_utf8 = false
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
test/functional/application_controller_test.rb
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2023 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require_relative '../test_helper'
class ApplicationControllerTest < Redmine::ControllerTest
def test_back_url_should_remove_utf8_checkmark_from_referer
@request.set_header 'HTTP_REFERER', "/path?utf8=\u2713&foo=bar"
assert_equal "/path?foo=bar", @controller.back_url
end
end
    (1-1/1)