merge revision(s) 42271: [Backport #8713]

* lib/uri/common.rb (URI.decode_www_form_component):
	  Don't raise error when str includes multibyte characters.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@42355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2013-08-03 13:27:01 +00:00
parent 65fcd2e738
commit a1525108b8
4 changed files with 12 additions and 2 deletions

View file

@ -1,3 +1,8 @@
Sat Aug 3 22:24:44 2013 Shota Fukumori <her@sorah.jp>
* lib/uri/common.rb (URI.decode_www_form_component):
Don't raise error when str includes multibyte characters.
Sun Jul 28 22:00:10 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Jul 28 22:00:10 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* rational.c (f_round_common): Rational is expected to be returned by * rational.c (f_round_common): Rational is expected to be returned by

View file

@ -896,7 +896,9 @@ module URI
# See URI.encode_www_form_component, URI.decode_www_form # See URI.encode_www_form_component, URI.decode_www_form
def self.decode_www_form_component(str, enc=Encoding::UTF_8) 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})" unless /\A[^%]*(?:%\h\h[^%]*)*\z/ =~ str
str.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc) str.dup.force_encoding("ASCII-8BIT") \
.gsub(/\+|%\h\h/, TBLDECWWWCOMP_) \
.force_encoding(enc)
end end
# Generate URL-encoded form data from given +enum+. # Generate URL-encoded form data from given +enum+.

View file

@ -69,6 +69,9 @@ class TestCommon < Test::Unit::TestCase
"AZ%5B%5C%5D%5E_%60az%7B%7C%7D%7E")) "AZ%5B%5C%5D%5E_%60az%7B%7C%7D%7E"))
assert_equal("\xA1\xA2".force_encoding(Encoding::EUC_JP), assert_equal("\xA1\xA2".force_encoding(Encoding::EUC_JP),
URI.decode_www_form_component("%A1%A2", "EUC-JP")) URI.decode_www_form_component("%A1%A2", "EUC-JP"))
assert_equal("\xE3\x81\x82\xE3\x81\x82".force_encoding("UTF-8"),
URI.decode_www_form_component("\xE3\x81\x82%E3%81%82".force_encoding("UTF-8")))
assert_raise(ArgumentError){URI.decode_www_form_component("%")} assert_raise(ArgumentError){URI.decode_www_form_component("%")}
end end

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0" #define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-08-03" #define RUBY_RELEASE_DATE "2013-08-03"
#define RUBY_PATCHLEVEL 284 #define RUBY_PATCHLEVEL 285
#define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 8 #define RUBY_RELEASE_MONTH 8