aboutsummaryrefslogtreecommitdiffstats
path: root/lib/uri
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-09 11:58:20 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-09 11:58:20 +0000
commit8a3c3b9c95955bba7f143c44136a043568d88b94 (patch)
tree778be4eadcecb92fbc9c5dd76e2a4d455077ff1a /lib/uri
parent1f2def7dd84da6477df1ef9b4e8b39f6ce6f04cb (diff)
downloadruby-8a3c3b9c95955bba7f143c44136a043568d88b94.tar.gz
* lib/uri/common.rb (decode_www_form): don't ignore leading '?'.
[ruby-dev:40938] * lib/uri/common.rb (decode_www_form): check whether argument is valid application/x-www-form-urlencoded data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri')
-rw-r--r--lib/uri/common.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index 5d0d95fb3f..a20ce0c981 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -805,6 +805,9 @@ module URI
str
end
+ # :nodoc:
+ WFKV_ = '(?:%\h\h|[^%#=;&])'
+
# Decode URL-encoded form data from given +str+.
#
# This decodes application/x-www-form-urlencoded data
@@ -826,11 +829,11 @@ module URI
#
# See URI.decode_www_form_component, URI.encode_www_form
def self.decode_www_form(str, enc=Encoding::UTF_8)
- ary = []
- unless /\A\??(?<query>[^=;&]*=[^;&]*(?:[;&][^=;&]*=[^;&]*)*)\z/ =~ str
+ unless /\A#{WFKV_}*=#{WFKV_}*(?:[;&]#{WFKV_}*=#{WFKV_}*)*\z/o =~ str
raise ArgumentError, "invalid data of application/x-www-form-urlencoded (#{str})"
end
- query.scan(/([^=;&]+)=([^;&]*)/) do
+ ary = []
+ $&.scan(/([^=;&]+)=([^;&]*)/) do
ary << [decode_www_form_component($1, enc), decode_www_form_component($2, enc)]
end
ary