mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
1 changed files with 1 additions and 1 deletions
|
@ -6,7 +6,7 @@ module CGI::Util
|
|||
# # => "%27Stop%21%27+said+Fred"
|
||||
def escape(string)
|
||||
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
|
||||
end.tr(' ', '+').force_encoding(encoding)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue