Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #407 from dayflower/spec_utils

Use backport of URI module even on ruby 1.9.2-p320
  • Loading branch information...
commit e4172e79b5b68e6bdd2ba45e3e590398fb456308 2 parents edc8b92 + f496e9b
Aaron Patterson tenderlove authored
41 lib/rack/backports/uri/common_192.rb
View
@@ -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
2  lib/rack/utils.rb
View
@@ -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'
1  test/spec_utils.rb
View
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
require 'rack/utils'
require 'rack/mock'
+require 'timeout'
describe Rack::Utils do
Please sign in to comment.
Something went wrong with that request. Please try again.