mirror of
https://github.com/redmine/redmine.git
synced 2025-12-16 05:20:28 +01:00
Ruby 2.7: Remove deprecated URI.escape/unescape (#32752).
Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@19455 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -441,12 +441,6 @@ Lint/UnusedBlockArgument:
|
|||||||
Lint/UnusedMethodArgument:
|
Lint/UnusedMethodArgument:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Lint/UriEscapeUnescape:
|
|
||||||
Exclude:
|
|
||||||
- 'lib/redmine/field_format.rb'
|
|
||||||
- 'lib/redmine/scm/adapters/subversion_adapter.rb'
|
|
||||||
- 'test/functional/wiki_controller_test.rb'
|
|
||||||
|
|
||||||
Lint/UselessAssignment:
|
Lint/UselessAssignment:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
|||||||
1
Gemfile
1
Gemfile
@@ -15,6 +15,7 @@ gem "csv", "~> 3.1.1"
|
|||||||
gem "nokogiri", "~> 1.10.0"
|
gem "nokogiri", "~> 1.10.0"
|
||||||
gem "i18n", "~> 1.6.0"
|
gem "i18n", "~> 1.6.0"
|
||||||
gem "rbpdf", "~> 1.20.0"
|
gem "rbpdf", "~> 1.20.0"
|
||||||
|
gem 'addressable'
|
||||||
|
|
||||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin]
|
gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin]
|
||||||
|
|||||||
@@ -269,15 +269,15 @@ module Redmine
|
|||||||
# %m1%, %m2%... => capture groups matches of the custom field regexp if defined
|
# %m1%, %m2%... => capture groups matches of the custom field regexp if defined
|
||||||
def url_from_pattern(custom_field, value, customized)
|
def url_from_pattern(custom_field, value, customized)
|
||||||
url = custom_field.url_pattern.to_s.dup
|
url = custom_field.url_pattern.to_s.dup
|
||||||
url.gsub!('%value%') {URI.encode value.to_s}
|
url.gsub!('%value%') {Addressable::URI.encode value.to_s}
|
||||||
url.gsub!('%id%') {URI.encode customized.id.to_s}
|
url.gsub!('%id%') {Addressable::URI.encode customized.id.to_s}
|
||||||
url.gsub!('%project_id%') {
|
url.gsub!('%project_id%') {
|
||||||
URI.encode(
|
Addressable::URI.encode(
|
||||||
(customized.respond_to?(:project) ? customized.project.try(:id) : nil).to_s
|
(customized.respond_to?(:project) ? customized.project.try(:id) : nil).to_s
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
url.gsub!('%project_identifier%') {
|
url.gsub!('%project_identifier%') {
|
||||||
URI.encode(
|
Addressable::URI.encode(
|
||||||
(customized.respond_to?(:project) ? customized.project.try(:identifier) : nil).to_s
|
(customized.respond_to?(:project) ? customized.project.try(:identifier) : nil).to_s
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ module Redmine
|
|||||||
url.gsub!(%r{%m(\d+)%}) do
|
url.gsub!(%r{%m(\d+)%}) do
|
||||||
m = $1.to_i
|
m = $1.to_i
|
||||||
if matches ||= value.to_s.match(Regexp.new(custom_field.regexp))
|
if matches ||= value.to_s.match(Regexp.new(custom_field.regexp))
|
||||||
URI.encode matches[m].to_s
|
Addressable::URI.encode matches[m].to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ module Redmine
|
|||||||
next if entry['kind'] == 'dir' && commit_date.nil?
|
next if entry['kind'] == 'dir' && commit_date.nil?
|
||||||
|
|
||||||
name = entry['name']['__content__']
|
name = entry['name']['__content__']
|
||||||
entries << Entry.new({:name => URI.unescape(name),
|
entries << Entry.new({:name => CGI.unescape(name),
|
||||||
:path => ((path.empty? ? "" : "#{path}/") + name),
|
:path => ((path.empty? ? "" : "#{path}/") + name),
|
||||||
:kind => entry['kind'],
|
:kind => entry['kind'],
|
||||||
:size => ((s = entry['size']) ? s['__content__'].to_i : nil),
|
:size => ((s = entry['size']) ? s['__content__'].to_i : nil),
|
||||||
@@ -289,7 +289,7 @@ module Redmine
|
|||||||
def target(path = '')
|
def target(path = '')
|
||||||
base = /^\//.match?(path) ? root_url : url
|
base = /^\//.match?(path) ? root_url : url
|
||||||
uri = "#{base}/#{path}"
|
uri = "#{base}/#{path}"
|
||||||
uri = URI.escape(URI.escape(uri), '[]')
|
uri = Addressable::URI.encode(uri)
|
||||||
shell_quote(uri.gsub(/[?<>\*]/, ''))
|
shell_quote(uri.gsub(/[?<>\*]/, ''))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1149,7 +1149,7 @@ class WikiControllerTest < Redmine::ControllerTest
|
|||||||
@request.user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063'
|
@request.user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063'
|
||||||
get :show, :params => {:project_id => 1, :id => title, :format => format}
|
get :show, :params => {:project_id => 1, :id => title, :format => format}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
filename = URI.encode("#{title}.#{format}")
|
filename = Addressable::URI.encode("#{title}.#{format}")
|
||||||
assert_equal "attachment; filename=\"#{filename}\"",
|
assert_equal "attachment; filename=\"#{filename}\"",
|
||||||
@response.headers['Content-Disposition']
|
@response.headers['Content-Disposition']
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user