[ruby-core:66060] Re: [ruby-cvs:55394] naruse:r48244 (trunk): * lib/uri/rfc3986_parser.rb (URI::RFC3986_Parser::RFC3986_URI):

From: Eric Wong <normalperson@...>
Date: 2014-11-03 02:39:13 UTC
List: ruby-core #66060
naruse@ruby-lang.org wrote:
>   http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48244

--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -851,7 +851,7 @@ module URI
       v.encode!(Encoding::UTF_8) rescue nil
       v.delete!("\t\r\n")
       v.force_encoding(Encoding::ASCII_8BIT)
-      v.gsub!(/(?!%\h\h|[!$-&(-;=?-_a-~])./n){'%%%02X' % $&.ord}
+      v.gsub!(/(?!%\h\h|[!$-&(-;=?-Z_a-~])./n.freeze){'%%%02X'.freeze % $&.ord}
       v.force_encoding(Encoding::US_ASCII)
       @query = v
     end

freeze a literal regexp?  I'm not familiar with regexp code,
so I'm wondering if there is a good reason for this.  Thanks.

Btw, I hope the freeze for String#% can be removed soon: [Feature #10423]

In This Thread

Prev Next