rack-contrib 1.7.0 → 1.8.0

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

Potentially problematic release.


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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0abe476c1066ae42097ede40ed8900fdea56f29
4
- data.tar.gz: 187747919618dda6f9c11d6c8ba7340fd74fc8e0
3
+ metadata.gz: bee6a82e9e3cd0238bfc695f9d18a74045235f86
4
+ data.tar.gz: a340facd62eb27f47bbce5e5e02f15c949454946
5
5
  SHA512:
6
- metadata.gz: 89db04752e24f7b780a89f8cc7edb6181b79d051034f5efc6b9c6194ce4b08fe99e2fd8416fb3c53e68bf55b07be1f1110a40866a49dff0c10ed94d6957bcee0
7
- data.tar.gz: 30ec6279d2da549cd25d54e5e3e0fb42809a9731563ead3e36e3c10cba6df3a1488e59821957d435eedc79b831aa538d4ffd26eba2a17295dcaf96fb6af38df2
6
+ metadata.gz: 6f3bee839cd6955789228948379912610ac8c9ea8dd2cfd2339f43b2e15e311ee0aacd65f71304977c2fb78624cd374a1b8e071e9129da0db2cde9e61828b64a
7
+ data.tar.gz: 5c0ce1dc50158e6790db66d758f7a9a16f6d5b0fa87a50f759e00c17d9a7ea5226ebc16e275f3f9e687306867d937bf1cadff224f763481f0991aa0650b58dc2
@@ -41,7 +41,7 @@ module Rack
41
41
  end
42
42
 
43
43
  headers = HeaderHash.new(headers)
44
-
44
+
45
45
  if is_json?(headers) && has_callback?(request)
46
46
  callback = request.params['callback']
47
47
  return bad_request unless valid_callback?(callback)
@@ -50,7 +50,7 @@ module Rack
50
50
 
51
51
  # No longer json, its javascript!
52
52
  headers['Content-Type'] = headers['Content-Type'].gsub('json', 'javascript')
53
-
53
+
54
54
  # Set new Content-Length, if it was set before we mutated the response body
55
55
  if headers['Content-Length']
56
56
  length = response.to_ary.inject(0) { |len, part| len + bytesize(part) }
@@ -60,22 +60,22 @@ module Rack
60
60
 
61
61
  [status, headers, response]
62
62
  end
63
-
63
+
64
64
  private
65
-
65
+
66
66
  def is_json?(headers)
67
67
  headers.key?('Content-Type') && headers['Content-Type'].include?('application/json')
68
68
  end
69
-
69
+
70
70
  def has_callback?(request)
71
71
  request.params.include?('callback') and not request.params['callback'].to_s.empty?
72
72
  end
73
73
 
74
74
  # See:
75
75
  # http://stackoverflow.com/questions/1661197/valid-characters-for-javascript-variable-names
76
- #
76
+ #
77
77
  # NOTE: Supports dots (.) since callbacks are often in objects:
78
- #
78
+ #
79
79
  def valid_callback?(callback)
80
80
  callback =~ VALID_CALLBACK
81
81
  end
@@ -98,7 +98,7 @@ module Rack
98
98
  # a string and should therefore not be present any other places.
99
99
  body << s.to_s.gsub(U2028, '\u2028').gsub(U2029, '\u2029')
100
100
  end
101
-
101
+
102
102
  # https://github.com/rack/rack-contrib/issues/46
103
103
  response.close if response.respond_to?(:close)
104
104
 
@@ -32,7 +32,7 @@ module Rack
32
32
  l.split(';q=')
33
33
  }
34
34
 
35
- lang = languages_and_qvalues.sort_by { |(locale, qvalue)|
35
+ language_and_qvalue = languages_and_qvalues.sort_by { |(locale, qvalue)|
36
36
  qvalue.to_f
37
37
  }.reverse.detect { |(locale, qvalue)|
38
38
  if I18n.enforce_available_locales
@@ -40,8 +40,9 @@ module Rack
40
40
  else
41
41
  true
42
42
  end
43
- }.first
43
+ }
44
44
 
45
+ lang = language_and_qvalue && language_and_qvalue.first
45
46
  lang == '*' ? nil : lang
46
47
  end
47
48
  end
@@ -127,6 +127,12 @@ module Rack
127
127
  elsif top.is_a? Hash
128
128
  key = CGI.unescape(key)
129
129
  parent << (@top = {}) if top.key?(key) && parent.is_a?(Array)
130
+
131
+ if top.include?(key) && value.is_a?(String)
132
+ warn "Rack::NestedParams' parsing behavior will change in rack-contrib 2.0"
133
+ warn "Currently 'foo=1&foo=2' is parsed to {'foo' => '1'}, in 2.0 it will be parsed to {'foo' => '2'}"
134
+ end
135
+
130
136
  top[key] ||= value
131
137
  return top[key]
132
138
  else
@@ -1,5 +1,7 @@
1
1
  require 'rack/file'
2
2
 
3
+ warn "rack-contrib deprecation warning: the rack-contrib version of Rack::Sendfile is deprecated and will be removed in rack-contrib 2.0. Please use the Rack::Sendfile from Rack 2.x instead."
4
+
3
5
  module Rack
4
6
 
5
7
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rack-devel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-01 00:00:00.000000000 Z
11
+ date: 2017-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack