Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Use backport of URI module even on ruby 1.9.2-p320 #407

Merged
merged 2 commits into from

3 participants

@dayflower

I do not know the reason, but MRI's bundled module uri/common still uses inproper regexp even on ruby 1.9.2-p320. So I have made change to use backport module on 1.9.2-p320 (and p318).
Also I've added missing dependency on timeout for test/spec_utils.rb. It will fix test failure on several platforms (ex. 1.9.3, 1.8.7, jruby) I believe.

@travisbot

This pull request passes (merged f496e9b into edc8b92).

@tenderlove
Owner

I'm merging this since the implementation matches trunk ruby. Presumably this isn't going to ever be backport to 1.9.2, so maybe we should stop doing the patchlevel checking before pulling in the backport.

@tenderlove tenderlove merged commit e4172e7 into rack:master
@dayflower dayflower deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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'
View
1  test/spec_utils.rb
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
require 'rack/utils'
require 'rack/mock'
+require 'timeout'
describe Rack::Utils do
Something went wrong with that request. Please try again.