Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use backport of URI module even on ruby 1.9.2-p320.

  • Loading branch information...
commit f496e9b525e32faa16818461947bb1dc2052fe04 1 parent 11a09b0
@dayflower dayflower authored
Showing with 12 additions and 31 deletions.
  1. +11 −30 lib/rack/backports/uri/common_192.rb
  2. +1 −1  lib/rack/utils.rb
View
41 lib/rack/backports/uri/common_192.rb
@@ -17,21 +17,18 @@
require 'uri/common'
module URI
- 256.times do |i|
- TBLENCWWWCOMP_[i.chr] = '%%%02X' % i
- end
- TBLENCWWWCOMP_[' '] = '+'
- TBLENCWWWCOMP_.freeze
-
- 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
+ TBLDECWWWCOMP_ = {} unless const_defined?(:TBLDECWWWCOMP_) #:nodoc:
+ if TBLDECWWWCOMP_.empty?
+ 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
end
- TBLDECWWWCOMP_['+'] = ' '
- TBLDECWWWCOMP_.freeze
def self.decode_www_form(str, enc=Encoding::UTF_8)
return [] if str.empty?
@@ -46,22 +43,6 @@ def self.decode_www_form(str, enc=Encoding::UTF_8)
end
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
View
2  lib/rack/utils.rb
@@ -9,7 +9,7 @@
if major == 1 && minor < 9
require 'rack/backports/uri/common_18'
-elsif major == 1 && minor == 9 && patch == 2 && RUBY_PATCHLEVEL < 318 && RUBY_ENGINE != 'jruby'
+elsif major == 1 && minor == 9 && patch == 2 && RUBY_PATCHLEVEL <= 320 && RUBY_ENGINE != 'jruby'
require 'rack/backports/uri/common_192'
elsif major == 1 && minor == 9 && patch == 3 && RUBY_PATCHLEVEL < 125
require 'rack/backports/uri/common_193'
Please sign in to comment.
Something went wrong with that request. Please try again.