summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-25 07:29:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-25 07:29:50 +0000
commit682f3a788102113fdb1927e2b42ef7932106acb2 (patch)
treee9e0403a8d1a41357764f7130c849ab77b806019 /lib
parent2bded596ecece11fe4ba34e851e14d91e2f5d19a (diff)
uri/common.rb: use negative look-ahead
* lib/uri/common.rb (URI.decode_www_form_component): use negative look-ahead instead of nested repeat operators, to get rid of backtrack explosion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/uri/common.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index 6378541cbe..00051a88fa 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -379,7 +379,7 @@ module URI
#
# See URI.encode_www_form_component, URI.decode_www_form
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
- raise ArgumentError, "invalid %-encoding (#{str})" unless /\A[^%]*(?:%\h\h[^%]*)*\z/ =~ str
+ raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
end