sprockets 4.2.0 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c5995147a647a6d47d625b6cc9f10586506f3832cff0070985ec9560ee3fc0d
4
- data.tar.gz: 1befd6f705efbef88f05dc58b38f719f11b445f76c60a95f854a43ef8e84c21d
3
+ metadata.gz: 6be8e97ff1bd7395fc078716cac0b775bacd30e1aad43153113df1b05b292164
4
+ data.tar.gz: e63069b6630898f92fe1853e51e7259714e126a44bd7b52442b9308533bee1d6
5
5
  SHA512:
6
- metadata.gz: 9d47aea08307515c8a0fab29615fbde5f892c91300668afd83b2739032adeb77794d4303e6ecb56c570bc784695d25304f7481fa45c4ab7bbe0727281ee7deab
7
- data.tar.gz: 6d0f0b116766053d96402f5d88602374829ef9610160bd8398a093db33ceaafe31a2f2b33a8d0c615769f0bbba7c39d867db90dfded9bc5ff35d0c0ff4482e36
6
+ metadata.gz: 37b62ffb61ca730485fcdf0526085a3eaabf21ebcc61f27f98510d4c013e7f64a0d5910879677a4d364bec5506b3d58a044ec4708e076a8791b3bf462699fdcd
7
+ data.tar.gz: 8d1178cbe5d033538d85a8ee9fb106bacc3ee7194d40332d42212f86298b458c3c45945a3be52320795f4fc1c3295d8ba27a4a05b2acefae24a191ee04a38c0f
data/CHANGELOG.md CHANGED
@@ -2,12 +2,29 @@
2
2
 
3
3
  Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprockets/blob/master/UPGRADING.md
4
4
 
5
+ ## 4.2.2
6
+
7
+ - Added missing dependency on `logger`. [#813](https://github.com/rails/sprockets/pull/813)
8
+ - Fix `URI::RFC3986_PARSER` warnings. [#812](https://github.com/rails/sprockets/pull/812)
9
+ - Removed dependency on `base64`. [#810](https://github.com/rails/sprockets/pull/810)
10
+
11
+ ## 4.2.1
12
+
13
+ - Fix for precompile issues when multiple extensions map to the same MIME type (eg. `.jpeg` / `.jpg`). [#781](https://github.com/rails/sprockets/pull/781)
14
+ - Fix `application/css-sourcemap+json` charset [#764](https://github.com/rails/sprockets/pull/764)
15
+ - Fix compatibility with Rack 2 applications. [#790](https://github.com/rails/sprockets/pull/790)
16
+
5
17
  ## 4.2.0
6
18
 
7
19
  - Rack 3 compatibility. [#758](https://github.com/rails/sprockets/pull/758)
8
20
  - Fix thread safety of `Sprockets::CachedEnvironment` and `Sprockets::Cache::MemoryStore`. [#771](https://github.com/rails/sprockets/pull/771)
9
21
  - Add support for Rack 3.0. Headers set by sprockets will now be lower case. [#758](https://github.com/rails/sprockets/pull/758)
10
22
  - Make `Sprockets::Utils.module_include` thread safe on JRuby. [#759](https://github.com/rails/sprockets/pull/759)
23
+ - Fix typo in `asset.rb` file. [#768](https://github.com/rails/sprockets/pull/768)
24
+
25
+ ## 4.1.1
26
+
27
+ - Fix `Sprockets::Server` to return response headers to be compatible with Rack::Lint 2.0.
11
28
 
12
29
  ## 4.1.0
13
30
 
@@ -137,7 +137,7 @@ module Sprockets
137
137
  DigestUtils.pack_hexdigest(digest)
138
138
  end
139
139
 
140
- # Pubic: ETag String of Asset.
140
+ # Public: ETag String of Asset.
141
141
  def etag
142
142
  version = environment_version
143
143
 
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'base64'
3
2
  require 'stringio'
4
3
  require 'zlib'
5
4
 
@@ -71,7 +70,7 @@ module Sprockets
71
70
  #
72
71
  # Returns a encoded String
73
72
  def base64(str)
74
- Base64.strict_encode64(str)
73
+ [str].pack("m0")
75
74
  end
76
75
 
77
76
 
@@ -165,7 +165,9 @@ module Sprockets
165
165
  end
166
166
 
167
167
  if type = unloaded.params[:type]
168
- logical_path += config[:mime_types][type][:extensions].first
168
+ extensions = config[:mime_types][type][:extensions]
169
+ extension = extensions.include?(extname) ? extname : extensions.first
170
+ logical_path += extension
169
171
  end
170
172
 
171
173
  if type != file_type && !config[:transformers][file_type][type]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require 'set'
3
3
  require 'time'
4
- require 'rack/utils'
4
+ require 'rack'
5
5
 
6
6
  module Sprockets
7
7
  # `Server` is a concern mixed into `Environment` and
@@ -11,6 +11,16 @@ module Sprockets
11
11
  # Supported HTTP request methods.
12
12
  ALLOWED_REQUEST_METHODS = ['GET', 'HEAD'].to_set.freeze
13
13
 
14
+ # :stopdoc:
15
+ if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3")
16
+ X_CASCADE = "X-Cascade"
17
+ VARY = "Vary"
18
+ else
19
+ X_CASCADE = "x-cascade"
20
+ VARY = "vary"
21
+ end
22
+ # :startdoc:
23
+
14
24
  # `call` implements the Rack 1.x specification which accepts an
15
25
  # `env` Hash and returns a three item tuple with the status code,
16
26
  # headers, and body.
@@ -148,39 +158,39 @@ module Sprockets
148
158
  # Returns a 400 Forbidden response tuple
149
159
  def bad_request_response(env)
150
160
  if head_request?(env)
151
- [ 400, { "content-type" => "text/plain", "content-length" => "0" }, [] ]
161
+ [ 400, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "0" }, [] ]
152
162
  else
153
- [ 400, { "content-type" => "text/plain", "content-length" => "11" }, [ "Bad Request" ] ]
163
+ [ 400, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "11" }, [ "Bad Request" ] ]
154
164
  end
155
165
  end
156
166
 
157
167
  # Returns a 403 Forbidden response tuple
158
168
  def forbidden_response(env)
159
169
  if head_request?(env)
160
- [ 403, { "content-type" => "text/plain", "content-length" => "0" }, [] ]
170
+ [ 403, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "0" }, [] ]
161
171
  else
162
- [ 403, { "content-type" => "text/plain", "content-length" => "9" }, [ "Forbidden" ] ]
172
+ [ 403, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "9" }, [ "Forbidden" ] ]
163
173
  end
164
174
  end
165
175
 
166
176
  # Returns a 404 Not Found response tuple
167
177
  def not_found_response(env)
168
178
  if head_request?(env)
169
- [ 404, { "content-type" => "text/plain", "content-length" => "0", "x-cascade" => "pass" }, [] ]
179
+ [ 404, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "0", X_CASCADE => "pass" }, [] ]
170
180
  else
171
- [ 404, { "content-type" => "text/plain", "content-length" => "9", "x-cascade" => "pass" }, [ "Not found" ] ]
181
+ [ 404, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "9", X_CASCADE => "pass" }, [ "Not found" ] ]
172
182
  end
173
183
  end
174
184
 
175
185
  def method_not_allowed_response
176
- [ 405, { "content-type" => "text/plain", "content-length" => "18" }, [ "Method Not Allowed" ] ]
186
+ [ 405, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "18" }, [ "Method Not Allowed" ] ]
177
187
  end
178
188
 
179
189
  def precondition_failed_response(env)
180
190
  if head_request?(env)
181
- [ 412, { "content-type" => "text/plain", "content-length" => "0", "x-cascade" => "pass" }, [] ]
191
+ [ 412, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "0", X_CASCADE => "pass" }, [] ]
182
192
  else
183
- [ 412, { "content-type" => "text/plain", "content-length" => "19", "x-cascade" => "pass" }, [ "Precondition Failed" ] ]
193
+ [ 412, { Rack::CONTENT_TYPE => "text/plain", Rack::CONTENT_LENGTH => "19", X_CASCADE => "pass" }, [ "Precondition Failed" ] ]
184
194
  end
185
195
  end
186
196
 
@@ -189,7 +199,7 @@ module Sprockets
189
199
  def javascript_exception_response(exception)
190
200
  err = "#{exception.class.name}: #{exception.message}\n (in #{exception.backtrace[0]})"
191
201
  body = "throw Error(#{err.inspect})"
192
- [ 200, { "content-type" => "application/javascript", "content-length" => body.bytesize.to_s }, [ body ] ]
202
+ [ 200, { Rack::CONTENT_TYPE => "application/javascript", Rack::CONTENT_LENGTH => body.bytesize.to_s }, [ body ] ]
193
203
  end
194
204
 
195
205
  # Returns a CSS response that hides all elements on the page and
@@ -242,7 +252,7 @@ module Sprockets
242
252
  }
243
253
  CSS
244
254
 
245
- [ 200, { "content-type" => "text/css; charset=utf-8", "content-length" => body.bytesize.to_s }, [ body ] ]
255
+ [ 200, { Rack::CONTENT_TYPE => "text/css; charset=utf-8", Rack::CONTENT_LENGTH => body.bytesize.to_s }, [ body ] ]
246
256
  end
247
257
 
248
258
  # Escape special characters for use inside a CSS content("...") string
@@ -258,18 +268,18 @@ module Sprockets
258
268
  headers = {}
259
269
 
260
270
  # Set caching headers
261
- headers["cache-control"] = +"public"
262
- headers["etag"] = %("#{etag}")
271
+ headers[Rack::CACHE_CONTROL] = +"public"
272
+ headers[Rack::ETAG] = %("#{etag}")
263
273
 
264
274
  # If the request url contains a fingerprint, set a long
265
275
  # expires on the response
266
276
  if path_fingerprint(env["PATH_INFO"])
267
- headers["cache-control"] << ", max-age=31536000, immutable"
277
+ headers[Rack::CACHE_CONTROL] << ", max-age=31536000, immutable"
268
278
 
269
279
  # Otherwise set `must-revalidate` since the asset could be modified.
270
280
  else
271
- headers["cache-control"] << ", must-revalidate"
272
- headers["vary"] = "Accept-Encoding"
281
+ headers[Rack::CACHE_CONTROL] << ", must-revalidate"
282
+ headers[VARY] = "Accept-Encoding"
273
283
  end
274
284
 
275
285
  headers
@@ -279,7 +289,7 @@ module Sprockets
279
289
  headers = {}
280
290
 
281
291
  # Set content length header
282
- headers["content-length"] = length.to_s
292
+ headers[Rack::CONTENT_LENGTH] = length.to_s
283
293
 
284
294
  # Set content type header
285
295
  if type = asset.content_type
@@ -287,7 +297,7 @@ module Sprockets
287
297
  if type.start_with?("text/") && asset.charset
288
298
  type += "; charset=#{asset.charset}"
289
299
  end
290
- headers["content-type"] = type
300
+ headers[Rack::CONTENT_TYPE] = type
291
301
  end
292
302
 
293
303
  headers.merge(cache_headers(env, asset.etag))
@@ -21,6 +21,9 @@ module Sprockets
21
21
  module URIUtils
22
22
  extend self
23
23
 
24
+ URI_PARSER = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::Generic::DEFAULT_PARSER
25
+ private_constant :URI_PARSER
26
+
24
27
  # Internal: Parse URI into component parts.
25
28
  #
26
29
  # uri - String uri
@@ -45,7 +48,7 @@ module Sprockets
45
48
  def split_file_uri(uri)
46
49
  scheme, _, host, _, _, path, _, query, _ = URI.split(uri)
47
50
 
48
- path = URI::Generic::DEFAULT_PARSER.unescape(path)
51
+ path = URI_PARSER.unescape(path)
49
52
  path.force_encoding(Encoding::UTF_8)
50
53
 
51
54
  # Hack for parsing Windows "/C:/Users/IEUser" paths
@@ -63,7 +66,7 @@ module Sprockets
63
66
  str = +"#{scheme}://"
64
67
  str << host if host
65
68
  path = "/#{path}" unless path.start_with?("/".freeze)
66
- str << URI::Generic::DEFAULT_PARSER.escape(path)
69
+ str << URI_PARSER.escape(path)
67
70
  str << "?#{query}" if query
68
71
  str
69
72
  end
@@ -162,7 +165,7 @@ module Sprockets
162
165
  when Integer
163
166
  query << "#{key}=#{value}"
164
167
  when String, Symbol
165
- query << "#{key}=#{URI::Generic::DEFAULT_PARSER.escape(value.to_s)}"
168
+ query << "#{key}=#{URI_PARSER.escape(value.to_s)}"
166
169
  when TrueClass
167
170
  query << "#{key}"
168
171
  when FalseClass, NilClass
@@ -182,7 +185,7 @@ module Sprockets
182
185
  def parse_uri_query_params(query)
183
186
  query.to_s.split('&'.freeze).reduce({}) do |h, p|
184
187
  k, v = p.split('='.freeze, 2)
185
- v = URI::Generic::DEFAULT_PARSER.unescape(v) if v
188
+ v = URI_PARSER.unescape(v) if v
186
189
  h[k.to_sym] = v || true
187
190
  h
188
191
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Sprockets
3
- VERSION = "4.2.0"
3
+ VERSION = "4.2.2"
4
4
  end
data/lib/sprockets.rb CHANGED
@@ -91,7 +91,7 @@ module Sprockets
91
91
 
92
92
  require 'sprockets/source_map_processor'
93
93
  register_mime_type 'application/js-sourcemap+json', extensions: ['.js.map'], charset: :unicode
94
- register_mime_type 'application/css-sourcemap+json', extensions: ['.css.map']
94
+ register_mime_type 'application/css-sourcemap+json', extensions: ['.css.map'], charset: :unicode
95
95
  register_transformer 'application/javascript', 'application/js-sourcemap+json', SourceMapProcessor
96
96
  register_transformer 'text/css', 'application/css-sourcemap+json', SourceMapProcessor
97
97
 
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
8
8
  - Joshua Peek
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2022-12-20 00:00:00.000000000 Z
11
+ date: 2025-04-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rack
@@ -45,6 +44,20 @@ dependencies:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
46
  version: '1.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: logger
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
48
61
  - !ruby/object:Gem::Dependency
49
62
  name: m
50
63
  requirement: !ruby/object:Gem::Requirement
@@ -233,14 +246,14 @@ dependencies:
233
246
  requirements:
234
247
  - - "~>"
235
248
  - !ruby/object:Gem::Version
236
- version: '12.0'
249
+ version: '13.2'
237
250
  type: :development
238
251
  prerelease: false
239
252
  version_requirements: !ruby/object:Gem::Requirement
240
253
  requirements:
241
254
  - - "~>"
242
255
  - !ruby/object:Gem::Version
243
- version: '12.0'
256
+ version: '13.2'
244
257
  - !ruby/object:Gem::Dependency
245
258
  name: sass
246
259
  requirement: !ruby/object:Gem::Requirement
@@ -423,7 +436,6 @@ homepage: https://github.com/rails/sprockets
423
436
  licenses:
424
437
  - MIT
425
438
  metadata: {}
426
- post_install_message:
427
439
  rdoc_options: []
428
440
  require_paths:
429
441
  - lib
@@ -438,8 +450,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
438
450
  - !ruby/object:Gem::Version
439
451
  version: '0'
440
452
  requirements: []
441
- rubygems_version: 3.3.7
442
- signing_key:
453
+ rubygems_version: 3.6.2
443
454
  specification_version: 4
444
455
  summary: Rack-based asset packaging system
445
456
  test_files: []