Project

General

Profile

Backport #5935 ยป backport.patch

tenderlovemaking (Aaron Patterson), 01/27/2012 05:08 AM

View differences:

ChangeLog
1
Tue Jan 24 11:38:05 2012  NARUSE, Yui  <naruse@ruby-lang.org>
2

  
3
	* lib/uri/common.rb (URI.encode_www_form_component): initialize on
4
	  requiring to support JRuby, which runs parallel multithreads.
5
	  [ruby-core:42222] [Bug #5925]
6

  
7
	* lib/uri/common.rb (URI.decode_www_form_component): initialize on
8

  
1 9
Mon Jan 16 16:41:53 2012  Nobuyoshi Nakada  <nobu@ruby-lang.org>
2 10

  
3 11
	* lib/optparse.rb (Regexp): fix incorrect options when casting to
lib/uri/common.rb
717 717
  end
718 718

  
719 719
  TBLENCWWWCOMP_ = {} # :nodoc:
720
  256.times do |i|
721
    TBLENCWWWCOMP_[i.chr] = '%%%02X' % i
722
  end
723
  TBLENCWWWCOMP_[' '] = '+'
724
  TBLENCWWWCOMP_.freeze
720 725
  TBLDECWWWCOMP_ = {} # :nodoc:
726
  256.times do |i|
727
    h, l = i>>4, i&15
728
    TBLDECWWWCOMP_['%%%X%X' % [h, l]] = i.chr
729
    TBLDECWWWCOMP_['%%%x%X' % [h, l]] = i.chr
730
    TBLDECWWWCOMP_['%%%X%x' % [h, l]] = i.chr
731
    TBLDECWWWCOMP_['%%%x%x' % [h, l]] = i.chr
732
  end
733
  TBLDECWWWCOMP_['+'] = ' '
734
  TBLDECWWWCOMP_.freeze
735

  
721 736
  HTML5ASCIIINCOMPAT = [Encoding::UTF_7, Encoding::UTF_16BE, Encoding::UTF_16LE,
722 737
    Encoding::UTF_32BE, Encoding::UTF_32LE] # :nodoc:
723 738

  
......
730 745
  #
731 746
  # See URI.decode_www_form_component, URI.encode_www_form
732 747
  def self.encode_www_form_component(str)
733
    if TBLENCWWWCOMP_.empty?
734
      tbl = {}
735
      256.times do |i|
736
        tbl[i.chr] = '%%%02X' % i
737
      end
738
      tbl[' '] = '+'
739
      begin
740
        TBLENCWWWCOMP_.replace(tbl)
741
        TBLENCWWWCOMP_.freeze
742
      rescue
743
      end
744
    end
745 748
    str = str.to_s
746 749
    if HTML5ASCIIINCOMPAT.include?(str.encoding)
747 750
      str = str.encode(Encoding::UTF_8)
......
759 762
  #
760 763
  # See URI.encode_www_form_component, URI.decode_www_form
761 764
  def self.decode_www_form_component(str, enc=Encoding::UTF_8)
762
    if TBLDECWWWCOMP_.empty?
763
      tbl = {}
764
      256.times do |i|
765
        h, l = i>>4, i&15
766
        tbl['%%%X%X' % [h, l]] = i.chr
767
        tbl['%%%x%X' % [h, l]] = i.chr
768
        tbl['%%%X%x' % [h, l]] = i.chr
769
        tbl['%%%x%x' % [h, l]] = i.chr
770
      end
771
      tbl['+'] = ' '
772
      begin
773
        TBLDECWWWCOMP_.replace(tbl)
774
        TBLDECWWWCOMP_.freeze
775
      rescue
776
      end
777
    end
778 765
    raise ArgumentError, "invalid %-encoding (#{str})" unless /\A(?:%\h\h|[^%]+)*\z/ =~ str
779 766
    str.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
780 767
  end
version.h
1 1
#define RUBY_VERSION "1.9.2"
2
#define RUBY_PATCHLEVEL 312
2
#define RUBY_PATCHLEVEL 313
3 3
#define RUBY_VERSION_MAJOR 1
4 4
#define RUBY_VERSION_MINOR 9
5 5
#define RUBY_VERSION_TEENY 1