diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-31 19:11:05 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-31 19:11:05 +0000 |
commit | 9cea14a8380b9e1f2f4bd8fec9e3c81bfe8056b0 (patch) | |
tree | 3afd8c5eeee37792b2e901889e1dd0cef5768029 | |
parent | 22271afb581b5f106df0ec6471fc417cb2202b40 (diff) |
merging r34364 from trunk into ruby_1_9_2
--
* lib/uri/common.rb (URI.encode_www_form_component): initialize on
requiring to support JRuby, which runs parallel multithreads.
[ruby-core:42222] [Bug #5925]
* lib/uri/common.rb (URI.decode_www_form_component): initialize on
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@34407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | lib/uri/common.rb | 43 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 24 insertions, 29 deletions
@@ -1,3 +1,11 @@ +Tue Jan 24 11:38:05 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/uri/common.rb (URI.encode_www_form_component): initialize on + requiring to support JRuby, which runs parallel multithreads. + [ruby-core:42222] [Bug #5925] + + * lib/uri/common.rb (URI.decode_www_form_component): initialize on + Mon Jan 16 16:41:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> * lib/optparse.rb (Regexp): fix incorrect options when casting to diff --git a/lib/uri/common.rb b/lib/uri/common.rb index ed8556c976..264fa053ed 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -717,7 +717,22 @@ module URI end TBLENCWWWCOMP_ = {} # :nodoc: + 256.times do |i| + TBLENCWWWCOMP_[i.chr] = '%%%02X' % i + end + TBLENCWWWCOMP_[' '] = '+' + TBLENCWWWCOMP_.freeze TBLDECWWWCOMP_ = {} # :nodoc: + 256.times do |i| + h, l = i>>4, i&15 + TBLDECWWWCOMP_['%%%X%X' % [h, l]] = i.chr + TBLDECWWWCOMP_['%%%x%X' % [h, l]] = i.chr + TBLDECWWWCOMP_['%%%X%x' % [h, l]] = i.chr + TBLDECWWWCOMP_['%%%x%x' % [h, l]] = i.chr + end + TBLDECWWWCOMP_['+'] = ' ' + TBLDECWWWCOMP_.freeze + HTML5ASCIIINCOMPAT = [Encoding::UTF_7, Encoding::UTF_16BE, Encoding::UTF_16LE, Encoding::UTF_32BE, Encoding::UTF_32LE] # :nodoc: @@ -730,18 +745,6 @@ module URI # # See URI.decode_www_form_component, URI.encode_www_form def self.encode_www_form_component(str) - if TBLENCWWWCOMP_.empty? - tbl = {} - 256.times do |i| - tbl[i.chr] = '%%%02X' % i - end - tbl[' '] = '+' - begin - TBLENCWWWCOMP_.replace(tbl) - TBLENCWWWCOMP_.freeze - rescue - end - end str = str.to_s if HTML5ASCIIINCOMPAT.include?(str.encoding) str = str.encode(Encoding::UTF_8) @@ -759,22 +762,6 @@ module URI # # See URI.encode_www_form_component, URI.decode_www_form def self.decode_www_form_component(str, enc=Encoding::UTF_8) - if TBLDECWWWCOMP_.empty? - tbl = {} - 256.times do |i| - h, l = i>>4, i&15 - tbl['%%%X%X' % [h, l]] = i.chr - tbl['%%%x%X' % [h, l]] = i.chr - tbl['%%%X%x' % [h, l]] = i.chr - tbl['%%%x%x' % [h, l]] = i.chr - end - tbl['+'] = ' ' - begin - TBLDECWWWCOMP_.replace(tbl) - TBLDECWWWCOMP_.freeze - rescue - end - end raise ArgumentError, "invalid %-encoding (#{str})" unless /\A(?:%\h\h|[^%]+)*\z/ =~ str str.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc) end @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 312 +#define RUBY_PATCHLEVEL 313 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |