sprockets 3.7.0 → 3.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +14 -2
- data/bin/sprockets +1 -0
- data/lib/sprockets/closure_compressor.rb +2 -1
- data/lib/sprockets/digest_utils.rb +12 -6
- data/lib/sprockets/directive_processor.rb +2 -0
- data/lib/sprockets/erb_processor.rb +13 -1
- data/lib/sprockets/manifest.rb +2 -1
- data/lib/sprockets/mime.rb +26 -6
- data/lib/sprockets/processing.rb +1 -1
- data/lib/sprockets/processor_utils.rb +1 -3
- data/lib/sprockets/resolve.rb +1 -1
- data/lib/sprockets/server.rb +34 -14
- data/lib/sprockets/uglifier_compressor.rb +2 -1
- data/lib/sprockets/uri_utils.rb +3 -0
- data/lib/sprockets/utils.rb +9 -4
- data/lib/sprockets/version.rb +1 -1
- data/lib/sprockets.rb +1 -1
- metadata +24 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d8d2739c5e14edf6aa95989aef8057d65eeb1525b4fccda72ba6099a8fe94bd3
|
4
|
+
data.tar.gz: 42fea69a2cf60adff7848fea3c8cd7fff222703611feda467aa8c5236aed9d84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 753ee6f089d3e281ba3eb81fe4fbd133d50065337f84c02891895de4544d2204bc884c1599781d632f290b1d407d684f473e101e5ba535f12afebc82a979cdd8
|
7
|
+
data.tar.gz: 9c57173eb38957dc992617903bd15b922caf20468c5952c158ffa00472c52ce6e0029011495f8b2fcd9a9148cd7b4ce3525b1749b3c9b1a982038ca9afe0e737
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,16 @@
|
|
1
|
-
**
|
1
|
+
**3.7.3** (March 28, 2024)
|
2
|
+
|
3
|
+
* Various compatibility fixes for newer Ruby versions.
|
4
|
+
|
5
|
+
**3.7.2** (June 19, 2018)
|
6
|
+
|
7
|
+
* Security release for [CVE-2018-3760](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-3760).
|
8
|
+
|
9
|
+
**3.7.1** (December 19, 2016)
|
10
|
+
|
11
|
+
* Ruby 2.4 support for Sprockets 3.
|
12
|
+
|
13
|
+
**3.7.0** (July 21, 2016)
|
2
14
|
|
3
15
|
* Deprecated interfaces now emit deprecation warnings #345
|
4
16
|
|
@@ -103,7 +115,7 @@
|
|
103
115
|
|
104
116
|
**3.0.0** (April 12, 2015)
|
105
117
|
|
106
|
-
[Guide to upgrading from Sprockets 2.x to 3.x](https://github.com/rails/sprockets/blob/
|
118
|
+
[Guide to upgrading from Sprockets 2.x to 3.x](https://github.com/rails/sprockets/blob/3.x/UPGRADING.md)
|
107
119
|
|
108
120
|
* New processor API. Tilt interface is deprecated.
|
109
121
|
* Improved file store caching backend.
|
data/bin/sprockets
CHANGED
@@ -35,11 +35,12 @@ module Sprockets
|
|
35
35
|
attr_reader :cache_key
|
36
36
|
|
37
37
|
def initialize(options = {})
|
38
|
-
@
|
38
|
+
@options = options
|
39
39
|
@cache_key = "#{self.class.name}:#{Autoload::Closure::VERSION}:#{Autoload::Closure::COMPILER_VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
|
40
40
|
end
|
41
41
|
|
42
42
|
def call(input)
|
43
|
+
@compiler ||= Autoload::Closure::Compiler.new(@options)
|
43
44
|
@compiler.compile(input[:data])
|
44
45
|
end
|
45
46
|
end
|
@@ -44,12 +44,8 @@ module Sprockets
|
|
44
44
|
digest << 'Symbol'.freeze
|
45
45
|
digest << val.to_s
|
46
46
|
},
|
47
|
-
|
48
|
-
digest << '
|
49
|
-
digest << val.to_s
|
50
|
-
},
|
51
|
-
Bignum => ->(val, digest) {
|
52
|
-
digest << 'Bignum'.freeze
|
47
|
+
Integer => ->(val, digest) {
|
48
|
+
digest << 'Integer'.freeze
|
53
49
|
digest << val.to_s
|
54
50
|
},
|
55
51
|
Array => ->(val, digest) {
|
@@ -73,6 +69,16 @@ module Sprockets
|
|
73
69
|
digest << val.name
|
74
70
|
},
|
75
71
|
}
|
72
|
+
if 0.class != Integer # Ruby < 2.4
|
73
|
+
ADD_VALUE_TO_DIGEST[Fixnum] = ->(val, digest) {
|
74
|
+
digest << 'Integer'.freeze
|
75
|
+
digest << val.to_s
|
76
|
+
}
|
77
|
+
ADD_VALUE_TO_DIGEST[Bignum] = ->(val, digest) {
|
78
|
+
digest << 'Integer'.freeze
|
79
|
+
digest << val.to_s
|
80
|
+
}
|
81
|
+
end
|
76
82
|
ADD_VALUE_TO_DIGEST.default_proc = ->(_, val) {
|
77
83
|
raise TypeError, "couldn't digest #{ val }"
|
78
84
|
}
|
@@ -18,7 +18,12 @@ module Sprockets
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def call(input)
|
21
|
-
|
21
|
+
if keyword_constructor? # Ruby 2.6+
|
22
|
+
engine = ::ERB.new(input[:data], trim_mode: '<>')
|
23
|
+
else
|
24
|
+
engine = ::ERB.new(input[:data], nil, '<>')
|
25
|
+
end
|
26
|
+
|
22
27
|
context = input[:environment].context_class.new(input)
|
23
28
|
klass = (class << context; self; end)
|
24
29
|
klass.class_eval(&@block) if @block
|
@@ -26,5 +31,12 @@ module Sprockets
|
|
26
31
|
data = context._evaluate_template
|
27
32
|
context.metadata.merge(data: data)
|
28
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def keyword_constructor?
|
38
|
+
return @keyword_constructor if defined? @keyword_constructor
|
39
|
+
@keyword_constructor = ::ERB.instance_method(:initialize).parameters.include?([:key, :trim_mode])
|
40
|
+
end
|
29
41
|
end
|
30
42
|
end
|
data/lib/sprockets/manifest.rb
CHANGED
data/lib/sprockets/mime.rb
CHANGED
@@ -111,17 +111,37 @@ module Sprockets
|
|
111
111
|
def compute_extname_map
|
112
112
|
graph = {}
|
113
113
|
|
114
|
+
engine_extname_permutation = []
|
115
|
+
|
116
|
+
4.times do |n|
|
117
|
+
config[:engines].keys.permutation(n).each do |engine_extnames|
|
118
|
+
engine_extname_permutation << engine_extnames
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
mime_exts_grouped_by_mime_type = {}
|
123
|
+
config[:mime_exts].each do |format_extname,format_type|
|
124
|
+
mime_exts_grouped_by_mime_type[format_type] ||= []
|
125
|
+
mime_exts_grouped_by_mime_type[format_type] << format_extname
|
126
|
+
end
|
127
|
+
|
114
128
|
([nil] + pipelines.keys.map(&:to_s)).each do |pipeline|
|
115
|
-
pipeline_extname = ".#{pipeline}"
|
116
|
-
|
117
|
-
|
118
|
-
|
129
|
+
pipeline_extname = pipeline ? ".#{pipeline}" : ''.freeze
|
130
|
+
engine_extname_permutation.each do |engine_extnames|
|
131
|
+
mime_exts_grouped_by_mime_type.each do |format_type, format_extnames|
|
132
|
+
type = format_type
|
133
|
+
value = [type, engine_extnames, pipeline]
|
134
|
+
format_extnames.each do |format_extname|
|
119
135
|
key = "#{pipeline_extname}#{format_extname}#{engine_extnames.join}"
|
120
|
-
|
121
|
-
|
136
|
+
graph[key] = value
|
137
|
+
end
|
138
|
+
if format_type == config[:engine_mime_types][engine_extnames.first]
|
139
|
+
key = "#{pipeline_extname}#{engine_extnames.join}"
|
140
|
+
graph[key] = value
|
122
141
|
end
|
123
142
|
end
|
124
143
|
end
|
144
|
+
graph[pipeline_extname] = [nil, [], pipeline]
|
125
145
|
end
|
126
146
|
|
127
147
|
graph
|
data/lib/sprockets/processing.rb
CHANGED
@@ -232,7 +232,7 @@ module Sprockets
|
|
232
232
|
end
|
233
233
|
|
234
234
|
def deprecate_legacy_processor_interface(interface)
|
235
|
-
msg = "You are using
|
235
|
+
msg = "You are using a deprecated processor interface #{ interface.inspect }.\n" +
|
236
236
|
"Please update your processor interface:\n" +
|
237
237
|
"https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors\n"
|
238
238
|
|
@@ -107,12 +107,10 @@ module Sprockets
|
|
107
107
|
VALID_METADATA_VALUE_TYPES = Set.new([
|
108
108
|
String,
|
109
109
|
Symbol,
|
110
|
-
Fixnum,
|
111
|
-
Bignum,
|
112
110
|
TrueClass,
|
113
111
|
FalseClass,
|
114
112
|
NilClass
|
115
|
-
]).freeze
|
113
|
+
] + (0.class == Integer ? [Integer] : [Bignum, Fixnum])).freeze
|
116
114
|
|
117
115
|
# Internal: Set of all nested compound metadata types that can nest values.
|
118
116
|
VALID_METADATA_COMPOUND_TYPES = Set.new([
|
data/lib/sprockets/resolve.rb
CHANGED
data/lib/sprockets/server.rb
CHANGED
@@ -23,7 +23,7 @@ module Sprockets
|
|
23
23
|
start_time = Time.now.to_f
|
24
24
|
time_elapsed = lambda { ((Time.now.to_f - start_time) * 1000).to_i }
|
25
25
|
|
26
|
-
if env['REQUEST_METHOD']
|
26
|
+
if !['GET', 'HEAD'].include?(env['REQUEST_METHOD'])
|
27
27
|
return method_not_allowed_response
|
28
28
|
end
|
29
29
|
|
@@ -39,7 +39,7 @@ module Sprockets
|
|
39
39
|
|
40
40
|
# URLs containing a `".."` are rejected for security reasons.
|
41
41
|
if forbidden_request?(path)
|
42
|
-
return forbidden_response
|
42
|
+
return forbidden_response(env)
|
43
43
|
end
|
44
44
|
|
45
45
|
# Look up the asset.
|
@@ -86,10 +86,10 @@ module Sprockets
|
|
86
86
|
not_modified_response(env, if_none_match)
|
87
87
|
when :not_found
|
88
88
|
logger.info "#{msg} 404 Not Found (#{time_elapsed.call}ms)"
|
89
|
-
not_found_response
|
89
|
+
not_found_response(env)
|
90
90
|
when :precondition_failed
|
91
91
|
logger.info "#{msg} 412 Precondition Failed (#{time_elapsed.call}ms)"
|
92
|
-
precondition_failed_response
|
92
|
+
precondition_failed_response(env)
|
93
93
|
end
|
94
94
|
rescue Exception => e
|
95
95
|
logger.error "Error compiling asset #{path}:"
|
@@ -115,12 +115,20 @@ module Sprockets
|
|
115
115
|
#
|
116
116
|
# http://example.org/assets/../../../etc/passwd
|
117
117
|
#
|
118
|
-
path.include?("..") || absolute_path?(path)
|
118
|
+
path.include?("..") || absolute_path?(path) || path.include?("://")
|
119
|
+
end
|
120
|
+
|
121
|
+
def head_request?(env)
|
122
|
+
env['REQUEST_METHOD'] == 'HEAD'
|
119
123
|
end
|
120
124
|
|
121
125
|
# Returns a 200 OK response tuple
|
122
126
|
def ok_response(asset, env)
|
123
|
-
|
127
|
+
if head_request?(env)
|
128
|
+
[ 200, headers(env, asset, 0), [] ]
|
129
|
+
else
|
130
|
+
[ 200, headers(env, asset, asset.length), asset ]
|
131
|
+
end
|
124
132
|
end
|
125
133
|
|
126
134
|
# Returns a 304 Not Modified response tuple
|
@@ -129,21 +137,33 @@ module Sprockets
|
|
129
137
|
end
|
130
138
|
|
131
139
|
# Returns a 403 Forbidden response tuple
|
132
|
-
def forbidden_response
|
133
|
-
|
140
|
+
def forbidden_response(env)
|
141
|
+
if head_request?(env)
|
142
|
+
[ 403, { "Content-Type" => "text/plain", "Content-Length" => "0" }, [] ]
|
143
|
+
else
|
144
|
+
[ 403, { "Content-Type" => "text/plain", "Content-Length" => "9" }, [ "Forbidden" ] ]
|
145
|
+
end
|
134
146
|
end
|
135
147
|
|
136
148
|
# Returns a 404 Not Found response tuple
|
137
|
-
def not_found_response
|
138
|
-
|
149
|
+
def not_found_response(env)
|
150
|
+
if head_request?(env)
|
151
|
+
[ 404, { "Content-Type" => "text/plain", "Content-Length" => "0", "X-Cascade" => "pass" }, [] ]
|
152
|
+
else
|
153
|
+
[ 404, { "Content-Type" => "text/plain", "Content-Length" => "9", "X-Cascade" => "pass" }, [ "Not found" ] ]
|
154
|
+
end
|
139
155
|
end
|
140
156
|
|
141
157
|
def method_not_allowed_response
|
142
158
|
[ 405, { "Content-Type" => "text/plain", "Content-Length" => "18" }, [ "Method Not Allowed" ] ]
|
143
159
|
end
|
144
160
|
|
145
|
-
def precondition_failed_response
|
146
|
-
|
161
|
+
def precondition_failed_response(env)
|
162
|
+
if head_request?(env)
|
163
|
+
[ 412, { "Content-Type" => "text/plain", "Content-Length" => "0", "X-Cascade" => "pass" }, [] ]
|
164
|
+
else
|
165
|
+
[ 412, { "Content-Type" => "text/plain", "Content-Length" => "19", "X-Cascade" => "pass" }, [ "Precondition Failed" ] ]
|
166
|
+
end
|
147
167
|
end
|
148
168
|
|
149
169
|
# Returns a JavaScript response that re-throws a Ruby exception
|
@@ -231,11 +251,11 @@ module Sprockets
|
|
231
251
|
# If the request url contains a fingerprint, set a long
|
232
252
|
# expires on the response
|
233
253
|
if path_fingerprint(env["PATH_INFO"])
|
234
|
-
headers["Cache-Control"]
|
254
|
+
headers["Cache-Control"] += ", max-age=31536000"
|
235
255
|
|
236
256
|
# Otherwise set `must-revalidate` since the asset could be modified.
|
237
257
|
else
|
238
|
-
headers["Cache-Control"]
|
258
|
+
headers["Cache-Control"] += ", must-revalidate"
|
239
259
|
headers["Vary"] = "Accept-Encoding"
|
240
260
|
end
|
241
261
|
|
@@ -44,11 +44,12 @@ module Sprockets
|
|
44
44
|
options[:comments] ||= :none
|
45
45
|
end
|
46
46
|
|
47
|
-
@
|
47
|
+
@options = options
|
48
48
|
@cache_key = "#{self.class.name}:#{Autoload::Uglifier::VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
|
49
49
|
end
|
50
50
|
|
51
51
|
def call(input)
|
52
|
+
@uglifier ||= Autoload::Uglifier.new(@options)
|
52
53
|
@uglifier.compile(input[:data])
|
53
54
|
end
|
54
55
|
end
|
data/lib/sprockets/uri_utils.rb
CHANGED
data/lib/sprockets/utils.rb
CHANGED
@@ -14,11 +14,15 @@ module Sprockets
|
|
14
14
|
#
|
15
15
|
# Returns false if .dup would raise a TypeError, otherwise true.
|
16
16
|
def duplicable?(obj)
|
17
|
-
|
18
|
-
when NilClass, FalseClass, TrueClass, Symbol, Numeric
|
19
|
-
false
|
20
|
-
else
|
17
|
+
if RUBY_VERSION >= "2.4.0"
|
21
18
|
true
|
19
|
+
else
|
20
|
+
case obj
|
21
|
+
when NilClass, FalseClass, TrueClass, Symbol, Numeric
|
22
|
+
false
|
23
|
+
else
|
24
|
+
true
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
@@ -98,6 +102,7 @@ module Sprockets
|
|
98
102
|
#
|
99
103
|
# Returns buf String.
|
100
104
|
def concat_javascript_sources(buf, source)
|
105
|
+
buf = +buf
|
101
106
|
if source.bytesize > 0
|
102
107
|
buf << source
|
103
108
|
|
data/lib/sprockets/version.rb
CHANGED
data/lib/sprockets.rb
CHANGED
@@ -105,7 +105,7 @@ module Sprockets
|
|
105
105
|
register_bundle_processor 'application/javascript', Bundle
|
106
106
|
register_bundle_processor 'text/css', Bundle
|
107
107
|
|
108
|
-
register_bundle_metadata_reducer '*/*', :data, proc { "" },
|
108
|
+
register_bundle_metadata_reducer '*/*', :data, proc { "" }, :+
|
109
109
|
register_bundle_metadata_reducer 'application/javascript', :data, proc { "" }, Utils.method(:concat_javascript_sources)
|
110
110
|
register_bundle_metadata_reducer '*/*', :links, :+
|
111
111
|
|
metadata
CHANGED
@@ -1,16 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.7.
|
4
|
+
version: 3.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
8
8
|
- Joshua Peek
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: base64
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: rack
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,16 +189,16 @@ dependencies:
|
|
175
189
|
name: rake
|
176
190
|
requirement: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
|
-
- - "
|
192
|
+
- - ">="
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
194
|
+
version: '0'
|
181
195
|
type: :development
|
182
196
|
prerelease: false
|
183
197
|
version_requirements: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
|
-
- - "
|
199
|
+
- - ">="
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
201
|
+
version: '0'
|
188
202
|
- !ruby/object:Gem::Dependency
|
189
203
|
name: sass
|
190
204
|
requirement: !ruby/object:Gem::Requirement
|
@@ -317,7 +331,7 @@ homepage: https://github.com/rails/sprockets
|
|
317
331
|
licenses:
|
318
332
|
- MIT
|
319
333
|
metadata: {}
|
320
|
-
post_install_message:
|
334
|
+
post_install_message:
|
321
335
|
rdoc_options: []
|
322
336
|
require_paths:
|
323
337
|
- lib
|
@@ -332,9 +346,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
332
346
|
- !ruby/object:Gem::Version
|
333
347
|
version: '0'
|
334
348
|
requirements: []
|
335
|
-
|
336
|
-
|
337
|
-
signing_key:
|
349
|
+
rubygems_version: 3.5.3
|
350
|
+
signing_key:
|
338
351
|
specification_version: 4
|
339
352
|
summary: Rack-based asset packaging system
|
340
353
|
test_files: []
|