[DRE-commits] [SCM] ruby-rack.git branch, upstream, updated. upstream/1.4.0-2-gb5a5247

Paul van Tilburg paulvt at debian.org
Tue Jan 3 21:59:17 UTC 2012


The following commit has been merged in the upstream branch:
commit b5a5247c54568620e8c3deb97c96559b11e157a7
Merge: e159324894bae9405eecb6464f86364b5750e779 45218b80b050548e9d8013fb9737a26fcc57aeae
Author: Paul van Tilburg <paulvt at debian.org>
Date:   Tue Jan 3 22:58:22 2012 +0100

    Merge remote-tracking branch 'origin/upstream' into upstream

diff --combined lib/rack/request.rb
index fbbf00b,10a4783..f7ff38c
--- a/lib/rack/request.rb
+++ b/lib/rack/request.rb
@@@ -72,8 -72,6 +72,8 @@@ module Rac
          'https'
        elsif @env['HTTP_X_FORWARDED_SSL'] == 'on'
          'https'
 +      elsif @env['HTTP_X_FORWARDED_SCHEME']
 +        @env['HTTP_X_FORWARDED_SCHEME']
        elsif @env['HTTP_X_FORWARDED_PROTO']
          @env['HTTP_X_FORWARDED_PROTO'].split(',')[0]
        else
@@@ -115,32 -113,15 +115,32 @@@
      def script_name=(s); @env["SCRIPT_NAME"] = s.to_s             end
      def path_info=(s);   @env["PATH_INFO"] = s.to_s               end
  
 +
 +    # Checks the HTTP request method (or verb) to see if it was of type DELETE
      def delete?;  request_method == "DELETE"  end
 +    
 +    # Checks the HTTP request method (or verb) to see if it was of type GET
      def get?;     request_method == "GET"     end
 +    
 +    # Checks the HTTP request method (or verb) to see if it was of type HEAD
      def head?;    request_method == "HEAD"    end
 +    
 +    # Checks the HTTP request method (or verb) to see if it was of type OPTIONS
      def options?; request_method == "OPTIONS" end
 +    
 +    # Checks the HTTP request method (or verb) to see if it was of type PATCH
      def patch?;   request_method == "PATCH"   end
 +    
 +    # Checks the HTTP request method (or verb) to see if it was of type POST
      def post?;    request_method == "POST"    end
 +    
 +    # Checks the HTTP request method (or verb) to see if it was of type PUT
      def put?;     request_method == "PUT"     end
 +    
 +    # Checks the HTTP request method (or verb) to see if it was of type TRACE
      def trace?;   request_method == "TRACE"   end
  
 +
      # The set of form-data media-types. Requests that do not indicate
      # one of the media types presents in this list will not be eligible
      # for form-data / param parsing.
@@@ -252,8 -233,8 +252,8 @@@
        hash   = @env["rack.request.cookie_hash"] ||= {}
        string = @env["HTTP_COOKIE"]
  
+       hash.clear unless string
        return hash if string == @env["rack.request.cookie_string"]
-       hash.clear
  
        # According to RFC 2109:
        #   If multiple cookies satisfy the criteria above, they are ordered in
@@@ -264,8 -245,7 +264,7 @@@
        @env["rack.request.cookie_string"] = string
        hash
      rescue => error
-       error.message.replace "cannot parse Cookie header: #{error.message}"
-       raise
+       raise error.class, "cannot parse Cookie header: #{error.message}"
      end
  
      def xhr?
@@@ -298,35 -278,23 +297,35 @@@
      end
  
      def accept_encoding
 -      @env["HTTP_ACCEPT_ENCODING"].to_s.split(/,\s*/).map do |part|
 -        m = /^([^\s,]+?)(?:;\s*q=(\d+(?:\.\d+)?))?$/.match(part) # From WEBrick
 -
 -        if m
 -          [m[1], (m[2] || 1.0).to_f]
 -        else
 -          raise "Invalid value for Accept-Encoding: #{part.inspect}"
 +      @env["HTTP_ACCEPT_ENCODING"].to_s.split(/\s*,\s*/).map do |part|
 +        encoding, parameters = part.split(/\s*;\s*/, 2)
 +        quality = 1.0
 +        if parameters and /\Aq=([\d.]+)/ =~ parameters
 +          quality = $1.to_f
          end
 +        [encoding, quality]
        end
      end
  
 +    def trusted_proxy?(ip)
 +      ip =~ /^127\.0\.0\.1$|^(10|172\.(1[6-9]|2[0-9]|30|31)|192\.168)\.|^::1$|^fd[0-9a-f]{2}:.+|^localhost$/i
 +    end
 +
      def ip
 -      if addr = @env['HTTP_X_FORWARDED_FOR']
 -        (addr.split(',').grep(/\d\./).first || @env['REMOTE_ADDR']).to_s.strip
 -      else
 -        @env['REMOTE_ADDR']
 +      remote_addrs = @env['REMOTE_ADDR'] ? @env['REMOTE_ADDR'].split(/[,\s]+/) : []
 +      remote_addrs.reject! { |addr| trusted_proxy?(addr) }
 +      
 +      return remote_addrs.first if remote_addrs.any?
 +
 +      forwarded_ips = @env['HTTP_X_FORWARDED_FOR'] ? @env['HTTP_X_FORWARDED_FOR'].strip.split(/[,\s]+/) : []
 +
 +      if client_ip = @env['HTTP_CLIENT_IP']
 +        # If forwarded_ips doesn't include the client_ip, it might be an
 +        # ip spoofing attempt, so we ignore HTTP_CLIENT_IP
 +        return client_ip if forwarded_ips.include?(client_ip)
        end
 +
 +      return forwarded_ips.reject { |ip| trusted_proxy?(ip) }.last || @env["REMOTE_ADDR"]
      end
  
      protected
diff --combined metadata.yml
index 3234b9b,6d51ad0..93a9077
--- a/metadata.yml
+++ b/metadata.yml
@@@ -1,13 -1,13 +1,13 @@@
  --- !ruby/object:Gem::Specification 
  name: rack
  version: !ruby/object:Gem::Version 
-   hash: 7
+   hash: 17
    prerelease: 
    segments: 
    - 1
-   - 4
-   - 0
-   version: 1.4.0
+   - 3
+   - 5
+   version: 1.3.5
  platform: ruby
  authors: 
  - Christian Neukirchen
@@@ -15,7 -15,7 +15,7 @@@ autorequire
  bindir: bin
  cert_chain: []
  
- date: 2011-12-28 00:00:00 Z
+ date: 2011-10-18 00:00:00 Z
  dependencies: 
  - !ruby/object:Gem::Dependency 
    name: bacon
@@@ -46,7 -46,7 +46,7 @@@
    type: :development
    version_requirements: *id002
  - !ruby/object:Gem::Dependency 
 -  name: fcgi
 +  name: ruby-fcgi
    prerelease: false
    requirement: &id003 !ruby/object:Gem::Requirement 
      none: false
@@@ -106,7 -106,7 +106,7 @@@
    type: :development
    version_requirements: *id006
  description: |
 -  Rack provides minimal, modular and adaptable interface for developing
 +  Rack provides a minimal, modular and adaptable interface for developing
    web applications in Ruby.  By wrapping HTTP requests and responses in
    the simplest way possible, it unifies and distills the API for web
    servers, web frameworks, and software in between (the so-called
@@@ -199,7 -199,6 +199,7 @@@ files
  - test/cgi/rackup_stub.rb
  - test/cgi/sample_rackup.ru
  - test/cgi/test
 +- test/cgi/test+directory/test+file
  - test/cgi/test.fcgi
  - test/cgi/test.ru
  - test/gemloader.rb
@@@ -269,7 -268,6 +269,7 @@@
  - test/spec_urlmap.rb
  - test/spec_utils.rb
  - test/spec_webrick.rb
 +- test/static/index.html
  - test/testrequest.rb
  - test/unregistered_handler/rack/handler/unregistered.rb
  - test/unregistered_handler/rack/handler/unregistered_long_one.rb
@@@ -308,7 -306,7 +308,7 @@@ required_rubygems_version: !ruby/object
  requirements: []
  
  rubyforge_project: rack
- rubygems_version: 1.8.12
+ rubygems_version: 1.8.11
  signing_key: 
  specification_version: 3
  summary: a modular Ruby webserver interface
diff --combined rack.gemspec
index 0d6fa07,e24f9ac..397bfc5
--- a/rack.gemspec
+++ b/rack.gemspec
@@@ -1,11 -1,11 +1,11 @@@
  Gem::Specification.new do |s|
    s.name            = "rack"
-   s.version         = "1.4.0"
+   s.version         = "1.3.5"
    s.platform        = Gem::Platform::RUBY
    s.summary         = "a modular Ruby webserver interface"
  
    s.description = <<-EOF
 -Rack provides minimal, modular and adaptable interface for developing
 +Rack provides a minimal, modular and adaptable interface for developing
  web applications in Ruby.  By wrapping HTTP requests and responses in
  the simplest way possible, it unifies and distills the API for web
  servers, web frameworks, and software in between (the so-called
@@@ -30,7 -30,7 +30,7 @@@ EO
    s.add_development_dependency 'bacon'
    s.add_development_dependency 'rake'
  
 -  s.add_development_dependency 'fcgi'
 +  s.add_development_dependency 'ruby-fcgi'
    s.add_development_dependency 'memcache-client'
    s.add_development_dependency 'mongrel', '>= 1.2.0.pre2'
    s.add_development_dependency 'thin'
diff --combined test/spec_conditionalget.rb
index 8b365eb,a21da45..820b082
--- a/test/spec_conditionalget.rb
+++ b/test/spec_conditionalget.rb
@@@ -3,13 -3,9 +3,13 @@@ require 'rack/conditionalget
  require 'rack/mock'
  
  describe Rack::ConditionalGet do
 +  def conditional_get(app)
 +    Rack::Lint.new Rack::ConditionalGet.new(app)
 +  end
 +  
    should "set a 304 status and truncate body when If-Modified-Since hits" do
      timestamp = Time.now.httpdate
 -    app = Rack::ConditionalGet.new(lambda { |env|
 +    app = conditional_get(lambda { |env|
        [200, {'Last-Modified'=>timestamp}, ['TEST']] })
  
      response = Rack::MockRequest.new(app).
@@@ -20,7 -16,7 +20,7 @@@
    end
  
    should "set a 304 status and truncate body when If-Modified-Since hits and is higher than current time" do
 -    app = Rack::ConditionalGet.new(lambda { |env|
 +    app = conditional_get(lambda { |env|
        [200, {'Last-Modified'=>(Time.now - 3600).httpdate}, ['TEST']] })
  
      response = Rack::MockRequest.new(app).
@@@ -31,7 -27,7 +31,7 @@@
    end
  
    should "set a 304 status and truncate body when If-None-Match hits" do
 -    app = Rack::ConditionalGet.new(lambda { |env|
 +    app = conditional_get(lambda { |env|
        [200, {'Etag'=>'1234'}, ['TEST']] })
  
      response = Rack::MockRequest.new(app).
@@@ -43,8 -39,8 +43,8 @@@
  
    should "not set a 304 status if If-Modified-Since hits but Etag does not" do
      timestamp = Time.now.httpdate
 -    app = Rack::ConditionalGet.new(lambda { |env|
 -      [200, {'Last-Modified'=>timestamp, 'Etag'=>'1234'}, ['TEST']] })
 +    app = conditional_get(lambda { |env|
 +      [200, {'Last-Modified'=>timestamp, 'Etag'=>'1234', 'Content-Type' => 'text/plain'}, ['TEST']] })
  
      response = Rack::MockRequest.new(app).
        get("/", 'HTTP_IF_MODIFIED_SINCE' => timestamp, 'HTTP_IF_NONE_MATCH' => '4321')
@@@ -55,7 -51,7 +55,7 @@@
  
    should "set a 304 status and truncate body when both If-None-Match and If-Modified-Since hits" do
      timestamp = Time.now.httpdate
 -    app = Rack::ConditionalGet.new(lambda { |env|
 +    app = conditional_get(lambda { |env|
        [200, {'Last-Modified'=>timestamp, 'Etag'=>'1234'}, ['TEST']] })
  
      response = Rack::MockRequest.new(app).
@@@ -66,8 -62,8 +66,8 @@@
    end
  
    should "not affect non-GET/HEAD requests" do
 -    app = Rack::ConditionalGet.new(lambda { |env|
 -      [200, {'Etag'=>'1234'}, ['TEST']] })
 +    app = conditional_get(lambda { |env|
 +      [200, {'Etag'=>'1234', 'Content-Type' => 'text/plain'}, ['TEST']] })
  
      response = Rack::MockRequest.new(app).
        post("/", 'HTTP_IF_NONE_MATCH' => '1234')
@@@ -77,8 -73,8 +77,8 @@@
    end
  
    should "not affect non-200 requests" do
 -    app = Rack::ConditionalGet.new(lambda { |env|
 -      [302, {'Etag'=>'1234'}, ['TEST']] })
 +    app = conditional_get(lambda { |env|
 +      [302, {'Etag'=>'1234', 'Content-Type' => 'text/plain'}, ['TEST']] })
  
      response = Rack::MockRequest.new(app).
        get("/", 'HTTP_IF_NONE_MATCH' => '1234')
@@@ -89,8 -85,8 +89,8 @@@
  
    should "not affect requests with malformed HTTP_IF_NONE_MATCH" do
      bad_timestamp = Time.now.strftime('%Y-%m-%d %H:%M:%S %z')
-     app = conditional_get(lambda { |env|
-       [200,{'Last-Modified'=>(Time.now - 3600).httpdate, 'Content-Type' => 'text/plain'}, ['TEST']] })
+     app = Rack::ConditionalGet.new(lambda { |env|
+       [200,{'Last-Modified'=>(Time.now - 3600).httpdate}, ['TEST']] })
  
      response = Rack::MockRequest.new(app).
        get("/", 'HTTP_IF_MODIFIED_SINCE' => bad_timestamp)
diff --combined test/spec_request.rb
index d20585c,0196267..8eb3cae
--- a/test/spec_request.rb
+++ b/test/spec_request.rb
@@@ -125,18 -125,6 +125,18 @@@ describe Rack::Request d
      req.params.should.equal "foo" => "bar", "quux" => "bla"
    end
  
 +  should "limit the keys from the GET query string" do
 +    env = Rack::MockRequest.env_for("/?foo=bar")
 +
 +    old, Rack::Utils.key_space_limit = Rack::Utils.key_space_limit, 1
 +    begin
 +      req = Rack::Request.new(env)
 +      lambda { req.GET }.should.raise(RangeError)
 +    ensure
 +      Rack::Utils.key_space_limit = old
 +    end
 +  end
 +
    should "not unify GET and POST when calling params" do
      mr = Rack::MockRequest.env_for("/?foo=quux",
        "REQUEST_METHOD" => 'POST',
@@@ -169,20 -157,6 +169,20 @@@
      req.params.should.equal "foo" => "bar", "quux" => "bla"
    end
  
 +  should "limit the keys from the POST form data" do
 +    env = Rack::MockRequest.env_for("",
 +            "REQUEST_METHOD" => 'POST',
 +            :input => "foo=bar&quux=bla")
 +
 +    old, Rack::Utils.key_space_limit = Rack::Utils.key_space_limit, 1
 +    begin
 +      req = Rack::Request.new(env)
 +      lambda { req.POST }.should.raise(RangeError)
 +    ensure
 +      Rack::Utils.key_space_limit = old
 +    end
 +  end
 +
    should "parse POST data with explicit content type regardless of method" do
      req = Rack::Request.new \
        Rack::MockRequest.env_for("/",
@@@ -359,17 -333,13 +359,17 @@@
      request.scheme.should.equal "https"
      request.should.be.ssl?
  
 +    request = Rack::Request.new(Rack::MockRequest.env_for("/", 'HTTP_X_FORWARDED_SCHEME' => 'https'))
 +    request.scheme.should.equal "https"
 +    request.should.be.ssl?
 +
      request = Rack::Request.new(Rack::MockRequest.env_for("/", 'HTTP_X_FORWARDED_PROTO' => 'https'))
      request.scheme.should.equal "https"
      request.should.be.ssl?
  
      request = Rack::Request.new(Rack::MockRequest.env_for("/", 'HTTP_X_FORWARDED_PROTO' => 'https, http, http'))
      request.scheme.should.equal "https"
 -    request.should.be.ssl
 +    request.should.be.ssl?
    end
  
    should "parse cookies" do
@@@ -387,15 -357,6 +387,6 @@@
      hash = req.cookies
      req.env.delete("HTTP_COOKIE")
      req.cookies.should.equal(hash)
-     req.env["HTTP_COOKIE"] = "zoo=m"
-     req.cookies.should.equal(hash)
-   end
- 
-   should "modify the cookies hash in place" do
-     req = Rack::Request.new(Rack::MockRequest.env_for(""))
-     req.cookies.should.equal({})
-     req.cookies['foo'] = 'bar'
-     req.cookies.should.equal 'foo' => 'bar'
    end
  
    should "raise any errors on every request" do
@@@ -787,98 -748,38 +778,98 @@@ EO
      parser.call("compress;q=0.5, gzip;q=1.0").should.equal([["compress", 0.5], ["gzip", 1.0]])
      parser.call("gzip;q=1.0, identity; q=0.5, *;q=0").should.equal([["gzip", 1.0], ["identity", 0.5], ["*", 0] ])
  
 -    lambda { parser.call("gzip ; q=1.0") }.should.raise(RuntimeError)
 +    parser.call("gzip ; q=0.9").should.equal([["gzip", 0.9]])
 +    parser.call("gzip ; deflate").should.equal([["gzip", 1.0]])
    end
  
 +  ip_app = lambda { |env|
 +    request = Rack::Request.new(env)
 +    response = Rack::Response.new
 +    response.write request.ip
 +    response.finish
 +  }
 +
    should 'provide ip information' do
 -    app = lambda { |env|
 -      request = Rack::Request.new(env)
 -      response = Rack::Response.new
 -      response.write request.ip
 -      response.finish
 -    }
 +    mock = Rack::MockRequest.new(Rack::Lint.new(ip_app))
  
 -    mock = Rack::MockRequest.new(Rack::Lint.new(app))
 -    res = mock.get '/', 'REMOTE_ADDR' => '123.123.123.123'
 -    res.body.should.equal '123.123.123.123'
 +    res = mock.get '/', 'REMOTE_ADDR' => '1.2.3.4'
 +    res.body.should.equal '1.2.3.4'
  
 -    res = mock.get '/',
 -      'REMOTE_ADDR' => '123.123.123.123',
 -      'HTTP_X_FORWARDED_FOR' => '234.234.234.234'
 +    res = mock.get '/', 'REMOTE_ADDR' => 'fe80::202:b3ff:fe1e:8329'
 +    res.body.should.equal 'fe80::202:b3ff:fe1e:8329'
 +
 +    res = mock.get '/', 'REMOTE_ADDR' => '1.2.3.4,3.4.5.6'
 +    res.body.should.equal '1.2.3.4'
 +  end
 +
 +  should 'deals with proxies' do
 +    mock = Rack::MockRequest.new(Rack::Lint.new(ip_app))
  
 -    res.body.should.equal '234.234.234.234'
 +    res = mock.get '/',
 +      'REMOTE_ADDR' => '1.2.3.4',
 +      'HTTP_X_FORWARDED_FOR' => '3.4.5.6'
 +    res.body.should.equal '1.2.3.4'
  
      res = mock.get '/',
 -      'REMOTE_ADDR' => '123.123.123.123',
 -      'HTTP_X_FORWARDED_FOR' => '234.234.234.234,212.212.212.212'
 +      'REMOTE_ADDR' => '127.0.0.1',
 +      'HTTP_X_FORWARDED_FOR' => '3.4.5.6'
 +    res.body.should.equal '3.4.5.6'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => 'unknown,3.4.5.6'
 +    res.body.should.equal '3.4.5.6'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '192.168.0.1,3.4.5.6'
 +    res.body.should.equal '3.4.5.6'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '10.0.0.1,3.4.5.6'
 +    res.body.should.equal '3.4.5.6'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '10.0.0.1, 10.0.0.1, 3.4.5.6'
 +    res.body.should.equal '3.4.5.6'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '127.0.0.1, 3.4.5.6'
 +    res.body.should.equal '3.4.5.6'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => 'unknown,192.168.0.1'
 +    res.body.should.equal 'unknown'
  
 -    res.body.should.equal '234.234.234.234'
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => 'other,unknown,192.168.0.1'
 +    res.body.should.equal 'unknown'
  
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => 'unknown,localhost,192.168.0.1'
 +    res.body.should.equal 'unknown'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '9.9.9.9, 3.4.5.6, 10.0.0.1, 172.31.4.4'
 +    res.body.should.equal '3.4.5.6'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '::1,2620:0:1c00:0:812c:9583:754b:ca11'
 +    res.body.should.equal '2620:0:1c00:0:812c:9583:754b:ca11'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '2620:0:1c00:0:812c:9583:754b:ca11,::1'
 +    res.body.should.equal '2620:0:1c00:0:812c:9583:754b:ca11'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => 'fd5b:982e:9130:247f:0000:0000:0000:0000,2620:0:1c00:0:812c:9583:754b:ca11'
 +    res.body.should.equal '2620:0:1c00:0:812c:9583:754b:ca11'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '2620:0:1c00:0:812c:9583:754b:ca11,fd5b:982e:9130:247f:0000:0000:0000:0000'
 +    res.body.should.equal '2620:0:1c00:0:812c:9583:754b:ca11'
 +
 +    res = mock.get '/',
 +      'HTTP_X_FORWARDED_FOR' => '1.1.1.1, 127.0.0.1',
 +      'HTTP_CLIENT_IP' => '1.1.1.1'
 +    res.body.should.equal '1.1.1.1'
 +
 +    # Spoofing attempt
      res = mock.get '/',
 -      'REMOTE_ADDR' => '123.123.123.123',
 -      'HTTP_X_FORWARDED_FOR' => 'unknown,234.234.234.234,212.212.212.212'
 +      'HTTP_X_FORWARDED_FOR' => '1.1.1.1',
 +      'HTTP_CLIENT_IP' => '2.2.2.2'
 +    res.body.should.equal '1.1.1.1'
 +
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '8.8.8.8, 9.9.9.9'
 +    res.body.should.equal '9.9.9.9'
  
 -    res.body.should.equal '234.234.234.234'
 +    res = mock.get '/', 'HTTP_X_FORWARDED_FOR' => '8.8.8.8, fe80::202:b3ff:fe1e:8329'
 +    res.body.should.equal 'fe80::202:b3ff:fe1e:8329'
    end
  
    class MyRequest < Rack::Request
diff --combined test/spec_utils.rb
index a787763,0e8935f..75bb68c
--- a/test/spec_utils.rb
+++ b/test/spec_utils.rb
@@@ -11,16 -11,6 +11,6 @@@ describe Rack::Utils d
      $KCODE = default_kcode if one8
    end
  
-   should "round trip binary data" do
-     r = [218, 0].pack 'CC'
-     if defined?(::Encoding)
-       z = Rack::Utils.unescape(Rack::Utils.escape(r), Encoding::BINARY)
-     else
-       z = Rack::Utils.unescape(Rack::Utils.escape(r))
-     end
-     r.should.equal z
-   end
- 
    should "escape correctly" do
      Rack::Utils.escape("fo<o>bar").should.equal "fo%3Co%3Ebar"
      Rack::Utils.escape("a space").should.equal "a+space"
@@@ -52,7 -42,7 +42,7 @@@
      should "unescape multibyte characters correctly if $KCODE is set to 'U'" do
        kcodeu do
          Rack::Utils.unescape('%E3%81%BE%E3%81%A4+%E3%82%82%E3%81%A8').should.equal(
-           "\xE3\x81\xBE\xE3\x81\xA4 \xE3\x82\x82\xE3\x81\xA8".unpack("a*")[0])
+         "\xE3\x81\xBE\xE3\x81\xA4 \xE3\x82\x82\xE3\x81\xA8".unpack("a*")[0])
        end
      end
    end
@@@ -217,22 -207,22 +207,22 @@@
      # unordered hash. Test that build_nested_query performs the inverse
      # function of parse_nested_query.
      [{"foo" => nil, "bar" => ""},
 -     {"foo" => "bar", "baz" => ""},
 -     {"foo" => ["1", "2"]},
 -     {"foo" => "bar", "baz" => ["1", "2", "3"]},
 -     {"foo" => ["bar"], "baz" => ["1", "2", "3"]},
 -     {"foo" => ["1", "2"]},
 -     {"foo" => "bar", "baz" => ["1", "2", "3"]},
 -     {"x" => {"y" => {"z" => "1"}}},
 -     {"x" => {"y" => {"z" => ["1"]}}},
 -     {"x" => {"y" => {"z" => ["1", "2"]}}},
 -     {"x" => {"y" => [{"z" => "1"}]}},
 -     {"x" => {"y" => [{"z" => ["1"]}]}},
 -     {"x" => {"y" => [{"z" => "1", "w" => "2"}]}},
 -     {"x" => {"y" => [{"v" => {"w" => "1"}}]}},
 -     {"x" => {"y" => [{"z" => "1", "v" => {"w" => "2"}}]}},
 -     {"x" => {"y" => [{"z" => "1"}, {"z" => "2"}]}},
 -     {"x" => {"y" => [{"z" => "1", "w" => "a"}, {"z" => "2", "w" => "3"}]}}
 +      {"foo" => "bar", "baz" => ""},
 +      {"foo" => ["1", "2"]},
 +      {"foo" => "bar", "baz" => ["1", "2", "3"]},
 +      {"foo" => ["bar"], "baz" => ["1", "2", "3"]},
 +      {"foo" => ["1", "2"]},
 +      {"foo" => "bar", "baz" => ["1", "2", "3"]},
 +      {"x" => {"y" => {"z" => "1"}}},
 +      {"x" => {"y" => {"z" => ["1"]}}},
 +      {"x" => {"y" => {"z" => ["1", "2"]}}},
 +      {"x" => {"y" => [{"z" => "1"}]}},
 +      {"x" => {"y" => [{"z" => ["1"]}]}},
 +      {"x" => {"y" => [{"z" => "1", "w" => "2"}]}},
 +      {"x" => {"y" => [{"v" => {"w" => "1"}}]}},
 +      {"x" => {"y" => [{"z" => "1", "v" => {"w" => "2"}}]}},
 +      {"x" => {"y" => [{"z" => "1"}, {"z" => "2"}]}},
 +      {"x" => {"y" => [{"z" => "1", "w" => "a"}, {"z" => "2", "w" => "3"}]}}
      ].each { |params|
        qs = Rack::Utils.build_nested_query(params)
        Rack::Utils.parse_nested_query(qs).should.equal params
@@@ -243,17 -233,6 +233,6 @@@
        message.should.equal "value must be a Hash"
    end
  
-   should "parse query strings that have a non-existent value" do
-     key = "post/2011/08/27/Deux-%22rat%C3%A9s%22-de-l-Universit"
-     Rack::Utils.parse_query(key).should.equal Rack::Utils.unescape(key) => nil
-   end
- 
-   should "build query strings without = with non-existent values" do
-     key = "post/2011/08/27/Deux-%22rat%C3%A9s%22-de-l-Universit"
-     key = Rack::Utils.unescape(key)
-     Rack::Utils.build_query(key => nil).should.equal Rack::Utils.escape(key)
-   end
- 
    should "escape html entities [&><'\"/]" do
      Rack::Utils.escape_html("foo").should.equal "foo"
      Rack::Utils.escape_html("f&o").should.equal "f&o"

-- 
ruby-rack.git



More information about the Pkg-ruby-extras-commits mailing list