[前][次][番号順一覧][スレッド一覧]

ruby-changes:19755

From: yugui <ko1@a...>
Date: Mon, 30 May 2011 07:54:02 +0900 (JST)
Subject: [ruby-changes:19755] yugui:r31799 (ruby_1_9_2): merges r31266 from trunk into ruby_1_9_2.

yugui	2011-05-30 07:49:36 +0900 (Mon, 30 May 2011)

  New Revision: 31799

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31799

  Log:
    merges r31266 from trunk into ruby_1_9_2.
    --
    * lib/uri/common.rb: avoid race condition. fixes #4572

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/lib/uri/common.rb
    branches/ruby_1_9_2/version.h

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 31798)
+++ ruby_1_9_2/ChangeLog	(revision 31799)
@@ -1,3 +1,7 @@
+Tue Apr 12 19:19:50 2011  NARUSE, Yui  <naruse@r...>
+
+	* lib/uri/common.rb: avoid race condition. fixes #4572
+
 Tue Apr 12 10:37:39 2011  NAKAMURA Usaku  <usa@r...>
 
 	* include/ruby/win32.h: VC doesn't have ftruncate() and others, but
Index: ruby_1_9_2/lib/uri/common.rb
===================================================================
--- ruby_1_9_2/lib/uri/common.rb	(revision 31798)
+++ ruby_1_9_2/lib/uri/common.rb	(revision 31799)
@@ -731,11 +731,16 @@
   # 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|
-        TBLENCWWWCOMP_[i.chr] = '%%%02X' % i
+        tbl[i.chr] = '%%%02X' % i
       end
-      TBLENCWWWCOMP_[' '] = '+'
-      TBLENCWWWCOMP_.freeze
+      tbl[' '] = '+'
+      begin
+        TBLENCWWWCOMP_.replace(tbl)
+        TBLENCWWWCOMP_.freeze
+      rescue
+      end
     end
     str = str.to_s
     if HTML5ASCIIINCOMPAT.include?(str.encoding)
@@ -755,15 +760,20 @@
   # 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
-        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
+        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
-      TBLDECWWWCOMP_['+'] = ' '
-      TBLDECWWWCOMP_.freeze
+      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)
Index: ruby_1_9_2/version.h
===================================================================
--- ruby_1_9_2/version.h	(revision 31798)
+++ ruby_1_9_2/version.h	(revision 31799)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 226
+#define RUBY_PATCHLEVEL 227
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 9
 #define RUBY_VERSION_TEENY 1

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]