sprockets 3.0.1 → 3.0.2

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

Potentially problematic release.


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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bd725a04a1285df9ad884d11fa77a3f2e00857b
4
- data.tar.gz: b2d4ca0a8689c24ba57a971147aeadccbcbfd9ce
3
+ metadata.gz: fce2476cd245660b43d7f43d8c73e49e8dba8f8b
4
+ data.tar.gz: 04a112134ed6023fc75a5f5932b9ce1e51200d55
5
5
  SHA512:
6
- metadata.gz: cb7d070feb9768f6b08fd19a9231ac16eda299732fdc60555eff057956009c11b87dd327761e5f9a010f1157dbcf74ce008dcda406fdebc839f9050300d230df
7
- data.tar.gz: 40360fc4bedbc30323ea5a02ddf3013af39bc1e6ae7723c0ad7b1c889c98236be061c14207c3d645eeae9e9d3aedbbdadbcddac56abc1d61fa11ce53d09f9dc4
6
+ metadata.gz: 67ae5f33aea980377bbab8a8f70b0fb0364a12696bc1c76c6813b03a11be59091d3630562d16cd0eeccfce1348661dc447989bdc54e34d0598578497f2d14c78
7
+ data.tar.gz: 611067448c1962a8a1fea6d50d0e236834f0244f66274ebd87f3bd0b2f2216ad67cdbe548186c3e34e28079bbbf4395286ad384eb13f48680c02a290478c7cd2
data/README.md CHANGED
@@ -449,193 +449,7 @@ submit a pull request.
449
449
 
450
450
  ### Version History
451
451
 
452
- **3.0.1** (April 14, 2015)
453
-
454
- * Fixed `Context#depend_on` with paths outside the load path
455
-
456
- **3.0.0** (April 12, 2015)
457
-
458
- * New processor API. Tilt interface is deprecated.
459
- * Improved file store caching backend.
460
- * MIME Types now accept charset custom charset detecters. Improves support for UTF-16/32 files.
461
- * Environment#version no longer affects asset digests. Only used for busting the asset cache.
462
- * Removed builtin support for LESS.
463
- * Removed `//= include` directive support.
464
- * Deprecated `BundledAsset#to_a`. Use `BundledAsset#included` to access debugging subcomponents.
465
- * Support circular dependencies. For parity with ES6 modules.
466
- * Manifest compilation will no longer generate .gz files by default. [Mixing
467
- Content-Encoding and ETags is just a bad
468
- idea](https://issues.apache.org/bugzilla/show_bug.cgi?id=39727)
469
- * Added linked or referenced assets. When an asset is compiled, any of its links will be compiled as well.
470
- * Introduce some limitations around enumerating all logical paths. 4.x will deprecate it and favor linked manifests for compliation.
471
- * Add Asset integrity attribute for Subresource Integrity
472
- * Default digest changed to SHA256. Configuring `digest_class` is deprecated.
473
- * Rename `Asset#digest` to `Asset#hexdigest`. `Asset#digest` is deprecated and will
474
- return a raw byte String in 4.x.
475
- * Added transitional compatibility flag to `Environment#resolve(path, compat: true)`. 2.x mode operates with `compat: true` and 4.x with `compat: false`
476
- * `manifest-abc123.json` renamed to `.sprockets-abc123.json`
477
-
478
- **2.12.3** (October 28, 2014)
479
-
480
- * Security: Fix directory traversal bug in development mode server.
481
-
482
- **2.12.2** (September 5, 2014)
483
-
484
- * Ensure internal asset lookups calls are still restricted to load paths within
485
- asset compiles. Though, you should not depend on internal asset resolves to be
486
- completely restricted for security reasons. Assets themselves should be
487
- considered full scripting environments with filesystem access.
488
-
489
- **2.12.1** (April 17, 2014)
490
-
491
- * Fix making manifest target directory when its different than the output directory.
492
-
493
- **2.12.0** (March 13, 2014)
494
-
495
- * Avoid context reference in SassImporter hack so its Marshallable. Fixes
496
- issues with Sass 3.3.x.
497
-
498
- **2.11.0** (February 19, 2014)
499
-
500
- * Cache store must now be an LRU implementation.
501
- * Default digest changed to SHA1. To continue using MD5.
502
- `env.digest_class = Digest::MD5`.
503
-
504
- **2.10.0** (May 24, 2013)
505
-
506
- * Support for `bower.json`
507
-
508
- **2.9.3** (April 20, 2013)
509
-
510
- * Fixed sass caching bug
511
-
512
- **2.9.2** (April 8, 2013)
513
-
514
- * Improve file freshness check performance
515
- * Directive processor encoding fixes
516
-
517
- **2.9.1** (April 6, 2013)
518
-
519
- * Support for Uglifier 2.x
520
-
521
- **2.9.0** (February 25, 2013)
522
-
523
- * Write out gzipped variants of bundled assets.
524
-
525
- **2.8.2** (December 10, 2012)
526
-
527
- * Fixed top level Sass constant references
528
- * Fixed manifest logger when environment is disabled
529
-
530
- **2.8.1** (October 31, 2012)
531
-
532
- * Fixed Sass importer bug
533
-
534
- **2.8.0** (October 16, 2012)
535
-
536
- * Allow manifest location to be separated from output directory
537
- * Pass logical path and absolute path to each_logical_path iterator
538
-
539
- **2.7.0** (October 10, 2012)
540
-
541
- * Added --css-compressor and --js-compressor command line flags
542
- * Added css/js compressor shorthand
543
- * Change default manifest.json filename to be a randomized manifest-16HEXBYTES.json
544
- * Allow nil environment to be passed to manifest
545
- * Allow manifest instance to be set on rake task
546
-
547
- **2.6.0** (September 19, 2012)
548
-
549
- * Added bower component.json require support
550
-
551
- **2.5.0** (September 4, 2012)
552
-
553
- * Fixed Ruby 2.0 RegExp warning
554
- * Provide stubbed implementation of context *_path helpers
555
- * Add SassCompressor
556
-
557
- **2.4.5** (July 10, 2012)
558
-
559
- * Tweaked some logger levels
560
-
561
- **2.4.4** (July 2, 2012)
562
-
563
- * Canonicalize logical path extensions
564
- * Check absolute paths passed to depend_on
565
-
566
- **2.4.3** (May 16, 2012)
567
-
568
- * Exposed :sprockets in sass options
569
- * Include dependency paths in asset mtime
570
-
571
- **2.4.2** (May 7, 2012)
572
-
573
- * Fixed MultiJson feature detect
574
-
575
- **2.4.1** (April 26, 2012)
576
-
577
- * Fixed MultiJson API change
578
- * Fixed gzip mtime
579
-
580
- **2.4.0** (March 27, 2012)
581
-
582
- * Added global path registry
583
- * Added global processor registry
584
-
585
- **2.3.2** (March 26, 2012)
586
-
587
- * Fix Context#logical_path with dots
588
-
589
- **2.3.1** (February 11, 2012)
590
-
591
- * Added bytesize to manifest
592
- * Added Asset#bytesize alias
593
- * Security: Check path for forbidden access after unescaping
594
-
595
- **2.3.0** (January 16, 2012)
596
-
597
- * Added special Sass importer that automatically tracks any `@import`ed files.
598
-
599
- **2.2.0** (January 10, 2012)
600
-
601
- * Added `sprockets` command line utility.
602
- * Added rake/sprocketstask.
603
- * Added json manifest log of compiled assets.
604
- * Added `stub` directive that allows you to exclude files from the bundle.
605
- * Added per environment external encoding (Environment#default_external_encoding). Defaults to UTF-8. Fixes issues where LANG is not set correctly and Rubys default external is set to ASCII.
606
-
607
- **2.1.2** (November 20, 2011)
608
-
609
- * Disabled If-Modified-Since server checks. Fixes some browser caching issues when serving the asset body only. If-None-Match caching is sufficient.
610
-
611
- **2.1.1** (November 18, 2011)
612
-
613
- * Fix windows absolute path check bug.
614
-
615
- **2.1.0** (November 11, 2011)
616
-
617
- * Directive comment lines are now turned into empty lines instead of removed. This way line numbers in
618
- CoffeeScript syntax errors are correct.
619
- * Performance and caching bug fixes.
620
-
621
- **2.0.3** (October 17, 2011)
622
-
623
- * Detect format extensions from right to left.
624
- * Make JST namespace configurable.
625
-
626
- **2.0.2** (October 4, 2011)
627
-
628
- * Fixed loading stale cache from bundler gems.
629
-
630
- **2.0.1** (September 30, 2011)
631
-
632
- * Fixed bug with fingerprinting file names with multiple dots.
633
- * Decode URIs as default internal.
634
- * Fix symlinked asset directories.
635
-
636
- **2.0.0** (August 29, 2011)
637
-
638
- * Initial public release.
452
+ Please see the [CHANGELOG](https://github.com/rails/sprockets/tree/master/CHANGELOG.md)
639
453
 
640
454
  ## License
641
455
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'sprockets/version'
2
3
  require 'sprockets/cache'
3
4
  require 'sprockets/environment'
@@ -101,8 +102,8 @@ module Sprockets
101
102
  register_bundle_processor 'application/javascript', Bundle
102
103
  register_bundle_processor 'text/css', Bundle
103
104
 
104
- register_bundle_metadata_reducer '*/*', :data, :+
105
- register_bundle_metadata_reducer 'application/javascript', :data, Utils.method(:concat_javascript_sources)
105
+ register_bundle_metadata_reducer '*/*', :data, proc { "" }, :concat
106
+ register_bundle_metadata_reducer 'application/javascript', :data, proc { "" }, Utils.method(:concat_javascript_sources)
106
107
  register_bundle_metadata_reducer '*/*', :links, :+
107
108
 
108
109
  require 'sprockets/closure_compressor'
@@ -44,7 +44,11 @@ module Sprockets
44
44
  def self.process_bundle_reducers(assets, reducers)
45
45
  initial = {}
46
46
  reducers.each do |k, (v, _)|
47
- initial[k] = v if !v.nil?
47
+ if v.respond_to?(:call)
48
+ initial[k] = v.call
49
+ elsif !v.nil?
50
+ initial[k] = v
51
+ end
48
52
  end
49
53
 
50
54
  assets.reduce(initial) do |h, asset|
@@ -104,7 +104,7 @@ module Sprockets
104
104
  charlock_detect(str)
105
105
  end
106
106
 
107
- # Fallback to UTF-8
107
+ # Fallback to environment's external encoding
108
108
  if str.encoding == Encoding::BINARY
109
109
  str.force_encoding(Encoding.default_external)
110
110
  end
@@ -233,7 +233,10 @@ module Sprockets
233
233
  nil
234
234
  end
235
235
 
236
- # Public: Detect charset from HTML document. Defaults to ISO-8859-1.
236
+ # Public: Detect charset from HTML document.
237
+ #
238
+ # Attempts to parse any Unicode BOM otherwise attempt Charlock detection
239
+ # and finally falls back to the environment's external encoding.
237
240
  #
238
241
  # str - String.
239
242
  #
@@ -246,9 +249,9 @@ module Sprockets
246
249
  charlock_detect(str)
247
250
  end
248
251
 
249
- # Fallback to ISO-8859-1
252
+ # Fallback to environment's external encoding
250
253
  if str.encoding == Encoding::BINARY
251
- str.force_encoding(Encoding::ISO_8859_1)
254
+ str.force_encoding(Encoding.default_external)
252
255
  end
253
256
 
254
257
  str
@@ -76,7 +76,9 @@ module Sprockets
76
76
  end
77
77
  end
78
78
 
79
- matches.sort_by { |match, quality| -quality }.map { |match, quality| match }
79
+ matches.sort_by! { |match, quality| -quality }
80
+ matches.map! { |match, quality| match }
81
+ matches
80
82
  end
81
83
 
82
84
  # Internal: Find the best qvalue match from an Array of available options.
@@ -29,7 +29,7 @@ module Sprockets
29
29
  def call(input)
30
30
  context = input[:environment].context_class.new(input)
31
31
  data = @proc.call(context, input[:data])
32
- context.metadata.merge(data: data)
32
+ context.metadata.merge(data: data.to_str)
33
33
  end
34
34
  end
35
35
  end
@@ -23,7 +23,7 @@ module Sprockets
23
23
  context = input[:environment].context_class.new(input)
24
24
 
25
25
  data = @klass.new(filename) { data }.render(context)
26
- context.metadata.merge(data: data)
26
+ context.metadata.merge(data: data.to_str)
27
27
  end
28
28
  end
29
29
  end
@@ -110,6 +110,7 @@ module Sprockets
110
110
  content_type: type,
111
111
  metadata: { dependencies: dependencies }
112
112
  })
113
+ validate_processor_result!(result)
113
114
  source = result.delete(:data)
114
115
  metadata = result.merge!(
115
116
  charset: source.encoding.name.downcase,
@@ -144,9 +145,9 @@ module Sprockets
144
145
  asset[:mtime] = metadata[:dependencies].map { |u|
145
146
  if u.start_with?("file-digest:")
146
147
  s = self.stat(parse_file_digest_uri(u))
147
- s ? s.mtime.to_i : 0
148
+ s ? s.mtime.to_i : 1211698800
148
149
  else
149
- 0
150
+ 1211698800
150
151
  end
151
152
  }.max
152
153
 
@@ -1,3 +1,5 @@
1
+ require 'set'
2
+
1
3
  module Sprockets
2
4
  # Functional utilities for dealing with Processor functions.
3
5
  #
@@ -99,5 +101,71 @@ module Sprockets
99
101
  def processors_cache_keys(processors)
100
102
  processors.map { |processor| processor_cache_key(processor) }
101
103
  end
104
+
105
+ # Internal: Set of all "simple" value types allowed to be returned in
106
+ # processor metadata.
107
+ VALID_METADATA_VALUE_TYPES = Set.new([
108
+ String,
109
+ Symbol,
110
+ Fixnum,
111
+ Bignum,
112
+ TrueClass,
113
+ FalseClass,
114
+ NilClass
115
+ ]).freeze
116
+
117
+ # Internal: Set of all nested compound metadata types that can nest values.
118
+ VALID_METADATA_COMPOUND_TYPES = Set.new([
119
+ Array,
120
+ Hash,
121
+ Set
122
+ ]).freeze
123
+
124
+ # Internal: Set of all allowed metadata types.
125
+ VALID_METADATA_TYPES = (VALID_METADATA_VALUE_TYPES + VALID_METADATA_COMPOUND_TYPES).freeze
126
+
127
+ # Internal: Validate returned result of calling a processor pipeline and
128
+ # raise a friendly user error message.
129
+ #
130
+ # result - Metadata Hash returned from call_processors
131
+ #
132
+ # Returns result or raises a TypeError.
133
+ def validate_processor_result!(result)
134
+ if !result.instance_of?(Hash)
135
+ raise TypeError, "processor metadata result was expected to be a Hash, but was #{result.class}"
136
+ end
137
+
138
+ if !result[:data].instance_of?(String)
139
+ raise TypeError, "processor :data was expected to be a String, but as #{result[:data].class}"
140
+ end
141
+
142
+ result.each do |key, value|
143
+ if !key.instance_of?(Symbol)
144
+ raise TypeError, "processor metadata[#{key.inspect}] expected to be a Symbol"
145
+ end
146
+
147
+ if !valid_processor_metadata_value?(value)
148
+ raise TypeError, "processor metadata[:#{key}] returned a complex type: #{value.inspect}\n" +
149
+ "Only #{VALID_METADATA_TYPES.to_a.join(", ")} maybe used."
150
+ end
151
+ end
152
+
153
+ result
154
+ end
155
+
156
+ # Internal: Validate object is in validate metadata whitelist.
157
+ #
158
+ # value - Any Object
159
+ #
160
+ # Returns true if class is in whitelist otherwise false.
161
+ def valid_processor_metadata_value?(value)
162
+ if VALID_METADATA_VALUE_TYPES.include?(value.class)
163
+ true
164
+ elsif VALID_METADATA_COMPOUND_TYPES.include?(value.class)
165
+ value.all? { |v| valid_processor_metadata_value?(v) }
166
+ else
167
+ false
168
+ end
169
+ end
102
170
  end
103
171
  end
@@ -53,7 +53,14 @@ module Sprockets
53
53
 
54
54
  unless uri
55
55
  message = "couldn't find file '#{path}'"
56
+
57
+ if relative_path?(path) && options[:base_path]
58
+ load_path, _ = paths_split(config[:paths], options[:base_path])
59
+ message << " under '#{load_path}'"
60
+ end
61
+
56
62
  message << " with type '#{options[:accept]}'" if options[:accept]
63
+
57
64
  raise FileNotFound, message
58
65
  end
59
66
 
@@ -51,7 +51,7 @@ module Sprockets
51
51
  path.force_encoding(Encoding::UTF_8)
52
52
 
53
53
  # Hack for parsing Windows "file:///C:/Users/IEUser" paths
54
- path = path.gsub(/^\/([a-zA-Z]:)/, '\1')
54
+ path.gsub!(/^\/([a-zA-Z]:)/, '\1')
55
55
 
56
56
  [scheme, host, path, query]
57
57
  end
@@ -183,7 +183,8 @@ module Sprockets
183
183
  query.to_s.split('&').reduce({}) do |h, p|
184
184
  k, v = p.split('=', 2)
185
185
  v = URI::Generic::DEFAULT_PARSER.unescape(v) if v
186
- h.merge(k.to_sym => v || true)
186
+ h[k.to_sym] = v || true
187
+ h
187
188
  end
188
189
  end
189
190
  end
@@ -90,15 +90,15 @@ module Sprockets
90
90
  # Internal: Accumulate asset source to buffer and append a trailing
91
91
  # semicolon if necessary.
92
92
  #
93
- # buf - String memo
94
- # asset - Asset
93
+ # buf - String buffer to append to
94
+ # source - String source to append
95
95
  #
96
- # Returns appended buffer String.
96
+ # Returns buf String.
97
97
  def concat_javascript_sources(buf, source)
98
98
  if string_end_with_semicolon?(buf)
99
- buf + source
99
+ buf << source
100
100
  else
101
- buf + ";\n" + source
101
+ buf << ";\n" << source
102
102
  end
103
103
  end
104
104
 
@@ -1,3 +1,3 @@
1
1
  module Sprockets
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-14 00:00:00.000000000 Z
12
+ date: 2015-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack