* lib/cgi/util.rb: Use String#b instead of dup.force_encoding("ASCII-8BIT")
[Feature #8394] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
940a99ac7c
commit
2829cbacc3
@ -6,7 +6,7 @@ module CGI::Util
|
|||||||
# # => "%27Stop%21%27+said+Fred"
|
# # => "%27Stop%21%27+said+Fred"
|
||||||
def escape(string)
|
def escape(string)
|
||||||
encoding = string.encoding
|
encoding = string.encoding
|
||||||
string.dup.force_encoding('ASCII-8BIT').gsub(/([^ a-zA-Z0-9_.-]+)/) do
|
string.b.gsub(/([^ a-zA-Z0-9_.-]+)/) do
|
||||||
'%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
|
'%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
|
||||||
end.tr(' ', '+').force_encoding(encoding)
|
end.tr(' ', '+').force_encoding(encoding)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user