* lib/cgi/util.rb, lib/erb.rb: Use String#b [Feature #8394] by znz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
021c2102dc
commit
012dc9d099
@ -1,3 +1,7 @@
|
|||||||
|
Sun Jun 2 15:04:35 2013 Zachary Scott <zachary@zacharyscott.net>
|
||||||
|
|
||||||
|
* lib/cgi/util.rb, lib/erb.rb: Use String#b [Feature #8394] by znz
|
||||||
|
|
||||||
Sun Jun 2 14:10:21 2013 Zachary Scott <zachary@zacharyscott.net>
|
Sun Jun 2 14:10:21 2013 Zachary Scott <zachary@zacharyscott.net>
|
||||||
|
|
||||||
* lib/irb/lc/help-message: Apply english updates for irb --help #7510
|
* lib/irb/lc/help-message: Apply english updates for irb --help #7510
|
||||||
|
@ -15,7 +15,7 @@ module CGI::Util
|
|||||||
# string = CGI::unescape("%27Stop%21%27+said+Fred")
|
# string = CGI::unescape("%27Stop%21%27+said+Fred")
|
||||||
# # => "'Stop!' said Fred"
|
# # => "'Stop!' said Fred"
|
||||||
def unescape(string,encoding=@@accept_charset)
|
def unescape(string,encoding=@@accept_charset)
|
||||||
str=string.tr('+', ' ').force_encoding(Encoding::ASCII_8BIT).gsub(/((?:%[0-9a-fA-F]{2})+)/) do
|
str=string.tr('+', ' ').b.gsub(/((?:%[0-9a-fA-F]{2})+)/) do
|
||||||
[$1.delete('%')].pack('H*')
|
[$1.delete('%')].pack('H*')
|
||||||
end.force_encoding(encoding)
|
end.force_encoding(encoding)
|
||||||
str.valid_encoding? ? str : str.force_encoding(string.encoding)
|
str.valid_encoding? ? str : str.force_encoding(string.encoding)
|
||||||
|
@ -596,7 +596,7 @@ class ERB
|
|||||||
def compile(s)
|
def compile(s)
|
||||||
enc = s.encoding
|
enc = s.encoding
|
||||||
raise ArgumentError, "#{enc} is not ASCII compatible" if enc.dummy?
|
raise ArgumentError, "#{enc} is not ASCII compatible" if enc.dummy?
|
||||||
s = s.dup.force_encoding("ASCII-8BIT") # don't use constant Enoding::ASCII_8BIT for miniruby
|
s = s.b # see String#b
|
||||||
enc = detect_magic_comment(s) || enc
|
enc = detect_magic_comment(s) || enc
|
||||||
out = Buffer.new(self, enc)
|
out = Buffer.new(self, enc)
|
||||||
|
|
||||||
@ -948,7 +948,7 @@ class ERB
|
|||||||
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
|
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
|
||||||
#
|
#
|
||||||
def url_encode(s)
|
def url_encode(s)
|
||||||
s.to_s.dup.force_encoding("ASCII-8BIT").gsub(/[^a-zA-Z0-9_\-.]/n) {
|
s.to_s.b.gsub(/[^a-zA-Z0-9_\-.]/n) {
|
||||||
sprintf("%%%02X", $&.unpack("C")[0])
|
sprintf("%%%02X", $&.unpack("C")[0])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user