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 +4 -4
- data/lib/rack/contrib/jsonp.rb +8 -8
- data/lib/rack/contrib/locale.rb +3 -2
- data/lib/rack/contrib/nested_params.rb +6 -0
- data/lib/rack/contrib/sendfile.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bee6a82e9e3cd0238bfc695f9d18a74045235f86
|
4
|
+
data.tar.gz: a340facd62eb27f47bbce5e5e02f15c949454946
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f3bee839cd6955789228948379912610ac8c9ea8dd2cfd2339f43b2e15e311ee0aacd65f71304977c2fb78624cd374a1b8e071e9129da0db2cde9e61828b64a
|
7
|
+
data.tar.gz: 5c0ce1dc50158e6790db66d758f7a9a16f6d5b0fa87a50f759e00c17d9a7ea5226ebc16e275f3f9e687306867d937bf1cadff224f763481f0991aa0650b58dc2
|
data/lib/rack/contrib/jsonp.rb
CHANGED
@@ -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
|
|
data/lib/rack/contrib/locale.rb
CHANGED
@@ -32,7 +32,7 @@ module Rack
|
|
32
32
|
l.split(';q=')
|
33
33
|
}
|
34
34
|
|
35
|
-
|
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
|
-
}
|
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
|
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.
|
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-
|
11
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|