rack 1.6.10 → 1.6.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 054e343b38a83a00ffc626cb6d3b92e21454c0fb
4
- data.tar.gz: 1f4c8f6e31f4e368371392a63d5232203be385d4
2
+ SHA256:
3
+ metadata.gz: b455a83d19e7b00bb4feb2287b28116434155cf52ea772cb9b532495f49938cc
4
+ data.tar.gz: 99a947eaf73e0207a642c92398e26062d5dc508455c72447e865a6aaec86dc5b
5
5
  SHA512:
6
- metadata.gz: 534da9c1e081350058c84fb1a1cc0c12beb6512f36fbd8f0651d96c2de6f5a911b9bbd900f88b0ca373b8b7c86a5d61f32d8c1ce6ef5e3ea1afd2dbf1c356451
7
- data.tar.gz: 973368cf843dcd7ff8854a4c9af6f9e48ffd1a30200a765c7a0102c475aa0adf1c469f43c4ef955234ed41d4e5f03d99305ec46aae3b07df901a7148eaaf179a
6
+ metadata.gz: ecc84a2788ac063238c547ea118a1e14624ace7ebc683cbf34842e57f5d4ac6fd843c4be0c3e717d7351da297a5e664f7b93255c2b37f3a73dc0939a4eb5596f
7
+ data.tar.gz: ff727aec584e743839a3a9c3fbe9f88d3c6c481b3f9fdf6f472a182b6caef19de7835c9a5222359fe5bb296eab79030df880e220756693fbc244b7fd5f05756c
@@ -20,7 +20,7 @@ module Rack
20
20
 
21
21
  # Return the Rack release as a dotted string.
22
22
  def self.release
23
- "1.6.10"
23
+ "1.6.11"
24
24
  end
25
25
  PATH_INFO = 'PATH_INFO'.freeze
26
26
  REQUEST_METHOD = 'REQUEST_METHOD'.freeze
@@ -13,6 +13,8 @@ module Rack
13
13
  # The environment of the request.
14
14
  attr_reader :env
15
15
 
16
+ SCHEME_WHITELIST = %w(https http).freeze
17
+
16
18
  def initialize(env)
17
19
  @env = env
18
20
  end
@@ -68,10 +70,8 @@ module Rack
68
70
  'https'
69
71
  elsif @env['HTTP_X_FORWARDED_SSL'] == 'on'
70
72
  'https'
71
- elsif @env['HTTP_X_FORWARDED_SCHEME']
72
- @env['HTTP_X_FORWARDED_SCHEME']
73
- elsif @env['HTTP_X_FORWARDED_PROTO']
74
- @env['HTTP_X_FORWARDED_PROTO'].split(',')[0]
73
+ elsif forwarded_scheme
74
+ forwarded_scheme
75
75
  else
76
76
  @env["rack.url_scheme"]
77
77
  end
@@ -394,5 +394,18 @@ module Rack
394
394
  s
395
395
  end
396
396
  end
397
+
398
+ def forwarded_scheme
399
+ scheme_headers = [
400
+ @env['HTTP_X_FORWARDED_SCHEME'],
401
+ @env['HTTP_X_FORWARDED_PROTO'].to_s.split(',')[0]
402
+ ]
403
+
404
+ scheme_headers.each do |header|
405
+ return header if SCHEME_WHITELIST.include?(header)
406
+ end
407
+
408
+ nil
409
+ end
397
410
  end
398
411
  end
@@ -47,7 +47,7 @@ module Rack
47
47
  end
48
48
 
49
49
  def prefers_plaintext?(env)
50
- !accepts_html(env)
50
+ !accepts_html?(env)
51
51
  end
52
52
 
53
53
  def accepts_html?(env)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rack"
3
- s.version = "1.6.10"
3
+ s.version = "1.6.11"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = "a modular Ruby webserver interface"
6
6
  s.license = "MIT"
@@ -425,6 +425,11 @@ describe Rack::Request do
425
425
  request.should.be.ssl?
426
426
  end
427
427
 
428
+ should "prevent scheme abuse" do
429
+ request = Rack::Request.new(Rack::MockRequest.env_for("/", 'HTTP_X_FORWARDED_SCHEME' => 'a."><script>alert(1)</script>'))
430
+ request.scheme.should.not.equal 'a."><script>alert(1)</script>'
431
+ end
432
+
428
433
  should "parse cookies" do
429
434
  req = Rack::Request.new \
430
435
  Rack::MockRequest.env_for("", "HTTP_COOKIE" => "foo=bar;quux=h&m")
@@ -82,4 +82,17 @@ describe Rack::ShowExceptions do
82
82
  res.should =~ /ShowExceptions/
83
83
  res.should =~ /unknown location/
84
84
  end
85
+
86
+ it "knows to prefer plaintext for non-html" do
87
+ # We don't need an app for this
88
+ exc = Rack::ShowExceptions.new(nil)
89
+
90
+ [
91
+ [{ "HTTP_ACCEPT" => "text/plain" }, true],
92
+ [{ "HTTP_ACCEPT" => "text/foo" }, true],
93
+ [{ "HTTP_ACCEPT" => "text/html" }, false]
94
+ ].each do |env, expected|
95
+ assert_equal(expected, exc.prefers_plaintext?(env))
96
+ end
97
+ end
85
98
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.10
4
+ version: 1.6.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Neukirchen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-23 00:00:00.000000000 Z
11
+ date: 2018-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bacon
@@ -256,57 +256,57 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  requirements: []
258
258
  rubyforge_project: rack
259
- rubygems_version: 2.6.13
259
+ rubygems_version: 2.7.6
260
260
  signing_key:
261
261
  specification_version: 4
262
262
  summary: a modular Ruby webserver interface
263
263
  test_files:
264
- - test/spec_auth_basic.rb
265
- - test/spec_auth_digest.rb
266
- - test/spec_body_proxy.rb
267
- - test/spec_builder.rb
268
- - test/spec_cascade.rb
269
- - test/spec_cgi.rb
270
- - test/spec_chunked.rb
271
- - test/spec_commonlogger.rb
272
- - test/spec_conditionalget.rb
273
- - test/spec_config.rb
274
- - test/spec_content_length.rb
275
- - test/spec_content_type.rb
264
+ - test/spec_multipart.rb
276
265
  - test/spec_deflater.rb
277
- - test/spec_directory.rb
266
+ - test/spec_static.rb
267
+ - test/spec_session_cookie.rb
268
+ - test/spec_commonlogger.rb
269
+ - test/spec_session_pool.rb
270
+ - test/spec_methodoverride.rb
278
271
  - test/spec_etag.rb
279
- - test/spec_fastcgi.rb
280
- - test/spec_file.rb
272
+ - test/spec_version.rb
281
273
  - test/spec_handler.rb
282
- - test/spec_head.rb
283
- - test/spec_lint.rb
284
- - test/spec_lobster.rb
285
- - test/spec_lock.rb
286
- - test/spec_logger.rb
287
- - test/spec_methodoverride.rb
274
+ - test/spec_thin.rb
275
+ - test/spec_showexceptions.rb
276
+ - test/spec_session_abstract_id.rb
288
277
  - test/spec_mime.rb
289
- - test/spec_mock.rb
290
- - test/spec_mongrel.rb
291
- - test/spec_multipart.rb
292
- - test/spec_nulllogger.rb
293
278
  - test/spec_recursive.rb
279
+ - test/spec_cgi.rb
280
+ - test/spec_content_type.rb
294
281
  - test/spec_request.rb
295
- - test/spec_response.rb
296
- - test/spec_rewindable_input.rb
282
+ - test/spec_showstatus.rb
283
+ - test/spec_chunked.rb
297
284
  - test/spec_runtime.rb
285
+ - test/spec_fastcgi.rb
286
+ - test/spec_builder.rb
287
+ - test/spec_config.rb
288
+ - test/spec_mongrel.rb
289
+ - test/spec_utils.rb
298
290
  - test/spec_sendfile.rb
299
- - test/spec_server.rb
300
- - test/spec_session_abstract_id.rb
301
- - test/spec_session_cookie.rb
302
- - test/spec_session_memcache.rb
303
- - test/spec_session_pool.rb
304
- - test/spec_showexceptions.rb
305
- - test/spec_showstatus.rb
306
- - test/spec_static.rb
291
+ - test/spec_lobster.rb
292
+ - test/spec_lint.rb
307
293
  - test/spec_tempfile_reaper.rb
308
- - test/spec_thin.rb
309
- - test/spec_urlmap.rb
310
- - test/spec_utils.rb
311
- - test/spec_version.rb
294
+ - test/spec_mock.rb
295
+ - test/spec_conditionalget.rb
296
+ - test/spec_server.rb
297
+ - test/spec_directory.rb
312
298
  - test/spec_webrick.rb
299
+ - test/spec_response.rb
300
+ - test/spec_file.rb
301
+ - test/spec_body_proxy.rb
302
+ - test/spec_logger.rb
303
+ - test/spec_auth_digest.rb
304
+ - test/spec_urlmap.rb
305
+ - test/spec_nulllogger.rb
306
+ - test/spec_cascade.rb
307
+ - test/spec_auth_basic.rb
308
+ - test/spec_head.rb
309
+ - test/spec_lock.rb
310
+ - test/spec_rewindable_input.rb
311
+ - test/spec_session_memcache.rb
312
+ - test/spec_content_length.rb