sassc-embedded 1.75.2 → 1.77.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf373b6b88c4dcdc3c784f85965562aa6e86ffffafd8ecb2b30513f2f52d51ae
4
- data.tar.gz: d29bad09cafd09e2a5953c46ec546fe9674fc022bbae0b9092d399d4902b621c
3
+ metadata.gz: d513301805669f2944f1dcc4f6ee8775554122531c7d41abca281c05acbb8351
4
+ data.tar.gz: 4a1576efa981b9c3e9b56a201793675d4764bb66b03cae8ea3f369eba9ed9f3f
5
5
  SHA512:
6
- metadata.gz: c0ecd4e0d91d6890d2b9312a7f39889d46f58095299fa3160a7f133e2dc5efd51734ea0577c80271fedb0601357e9231d6beadd24dbff0e7e54a5b1a048ea74c
7
- data.tar.gz: b58e4c56f4e3e41796f497885107f63765b91ec2fe81171cdc27b4d6d5d0a82909776a7453f723eee666f4e1cfedf1bedab35a75632517959e4e0cbe3b2ba909
6
+ metadata.gz: 10bf726fb6e87dabcdb0003c8dd104675233fc56800bac7b27b13ce936e568bf0c24ec7638325aa30bba01320b5e8b2f0bb95d93a69126fdd60df515382edf65
7
+ data.tar.gz: 4998fcb9dd6b735b93802d32ea5067834e75dedcfd2ba6ee32debc3ec24bbe8dc6f6cb0347a265596f2ae0b3f00b78e436282f264f144bd9ee7e401f1fed3395
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SassC
4
4
  module Embedded
5
- VERSION = '1.75.2'
5
+ VERSION = '1.77.0'
6
6
  end
7
7
  end
@@ -46,11 +46,11 @@ module SassC
46
46
  css = result.css
47
47
  css += "\n" unless css.empty?
48
48
  unless @source_map.nil? || omit_source_map_url?
49
- url = URL.parse(output_url || file_url)
49
+ url = URI.parse(output_url || file_url)
50
50
  source_mapping_url = if source_map_embed?
51
51
  "data:application/json;base64,#{[@source_map].pack('m0')}"
52
52
  else
53
- URL.file_urls_to_relative_url(source_map_file_url, url)
53
+ URI.file_urls_to_relative_url(source_map_file_url, url)
54
54
  end
55
55
  css += "\n/*# sourceMappingURL=#{source_mapping_url} */"
56
56
  end
@@ -61,9 +61,7 @@ module SassC
61
61
  line = e.span&.start&.line
62
62
  line += 1 unless line.nil?
63
63
  url = e.span&.url
64
- path = if url&.start_with?(Protocol::FILE)
65
- URL.file_urls_to_relative_path(url, URL.path_to_file_url("#{Dir.pwd}/"))
66
- end
64
+ path = (URI.file_urls_to_relative_path(url, URI.path_to_file_url("#{Dir.pwd}/")) if url&.start_with?('file:'))
67
65
  raise SyntaxError.new(e.full_message, filename: path, line:)
68
66
  end
69
67
 
@@ -71,19 +69,19 @@ module SassC
71
69
  raise NotRenderedError unless @loaded_urls
72
70
 
73
71
  Dependency.from_filenames(@loaded_urls.filter_map do |url|
74
- URL.file_url_to_path(url) if url.start_with?(Protocol::FILE) && url != file_url
72
+ URI.file_url_to_path(url) if url.start_with?('file:') && !url.include?('?') && url != file_url
75
73
  end)
76
74
  end
77
75
 
78
76
  def source_map
79
77
  raise NotRenderedError unless @source_map
80
78
 
81
- url = URL.parse(source_map_file_url || file_url)
79
+ url = URI.parse(source_map_file_url || file_url)
82
80
  data = JSON.parse(@source_map)
83
- data['file'] = URL.file_urls_to_relative_url(output_url, url) if output_url
81
+ data['file'] = URI.file_urls_to_relative_url(output_url, url) if output_url
84
82
  data['sources'].map! do |source|
85
- if source.start_with?(Protocol::FILE)
86
- URL.file_urls_to_relative_url(source, url)
83
+ if source.start_with?('file:')
84
+ URI.file_urls_to_relative_url(source, url)
87
85
  else
88
86
  source
89
87
  end
@@ -95,7 +93,7 @@ module SassC
95
93
  private
96
94
 
97
95
  def file_url
98
- @file_url ||= URL.path_to_file_url(File.absolute_path(filename || 'stdin'))
96
+ @file_url ||= URI.path_to_file_url(File.absolute_path(filename || 'stdin'))
99
97
  end
100
98
 
101
99
  def output_path
@@ -105,11 +103,18 @@ module SassC
105
103
  end
106
104
 
107
105
  def output_url
108
- @output_url ||= (URL.path_to_file_url(File.absolute_path(output_path)) if output_path)
106
+ @output_url ||= (URI.path_to_file_url(File.absolute_path(output_path)) if output_path)
109
107
  end
110
108
 
111
109
  def source_map_file_url
112
- @source_map_file_url ||= (URL.path_to_file_url(File.absolute_path(source_map_file)) if source_map_file)
110
+ @source_map_file_url ||= if source_map_file
111
+ # https://github.com/sass-contrib/sassc-embedded-shim-ruby/pull/69
112
+ # SassC does not encode path as uri for sourceMappingURL, which is technically wrong.
113
+ # However, this behavior has been abused to append query string to sourceMappingURL.
114
+ components = source_map_file.split('?', 2)
115
+ components[0] = URI.path_to_file_url(File.absolute_path(components[0]))
116
+ components.join('?')
117
+ end
113
118
  end
114
119
 
115
120
  def output_style
@@ -308,37 +313,31 @@ module SassC
308
313
  end
309
314
 
310
315
  def canonicalize(url, context)
311
- return if context.containing_url.nil?
316
+ return unless context.containing_url&.start_with?('file:')
312
317
 
313
- containing_url = if context.containing_url.start_with?(Protocol::GLOB)
314
- URL.unescape(URL.parse(context.containing_url).fragment)
315
- else
316
- context.containing_url
317
- end
318
+ containing_url = context.containing_url
318
319
 
319
- return unless containing_url.start_with?(Protocol::FILE)
320
-
321
- path = URL.unescape(url)
322
- parent_path = URL.file_url_to_path(containing_url)
320
+ path = URI.decode_uri_component(url)
321
+ parent_path = URI.file_url_to_path(containing_url)
323
322
  parent_dir = File.dirname(parent_path)
324
323
 
325
- if containing_url == context.containing_url
326
- imports = @importer.imports(path, parent_path)
327
- imports = [SassC::Importer::Import.new(path)] if imports.nil?
328
- imports = [imports] unless imports.is_a?(Array)
329
- canonical_url = imports_to_native(imports, parent_dir, context.from_import, url, context.containing_url)
324
+ if containing_url.include?('?')
325
+ canonical_url = URI.path_to_file_url(File.absolute_path(path, parent_dir))
330
326
  if @importer_results.key?(canonical_url)
331
327
  canonical_url
332
328
  else
333
- @file_url = canonical_url
329
+ @file_url = resolve_file_url(path, parent_dir, context.from_import)
334
330
  nil
335
331
  end
336
332
  else
337
- canonical_url = URL.path_to_file_url(File.absolute_path(path, parent_dir))
333
+ imports = @importer.imports(path, parent_path)
334
+ imports = [SassC::Importer::Import.new(path)] if imports.nil?
335
+ imports = [imports] unless imports.is_a?(Array)
336
+ canonical_url = imports_to_native(imports, parent_dir, context.from_import, url, containing_url)
338
337
  if @importer_results.key?(canonical_url)
339
338
  canonical_url
340
339
  else
341
- @file_url = resolve_file_url(path, parent_dir, context.from_import)
340
+ @file_url = canonical_url
342
341
  nil
343
342
  end
344
343
  end
@@ -360,7 +359,7 @@ module SassC
360
359
 
361
360
  def resolve_file_url(path, parent_dir, from_import)
362
361
  resolved = FileSystemImporter.resolve_path(File.absolute_path(path, parent_dir), from_import)
363
- URL.path_to_file_url(resolved) unless resolved.nil?
362
+ URI.path_to_file_url(resolved) unless resolved.nil?
364
363
  end
365
364
 
366
365
  def syntax(path)
@@ -376,7 +375,7 @@ module SassC
376
375
 
377
376
  def import_to_native(import, parent_dir, from_import, canonicalize)
378
377
  if import.source
379
- canonical_url = URL.path_to_file_url(File.absolute_path(import.path, parent_dir))
378
+ canonical_url = URI.path_to_file_url(File.absolute_path(import.path, parent_dir))
380
379
  @importer_results[canonical_url] = if import.source.is_a?(Hash)
381
380
  {
382
381
  contents: import.source[:contents],
@@ -395,13 +394,13 @@ module SassC
395
394
  return resolve_file_url(import.path, parent_dir, from_import)
396
395
  end
397
396
 
398
- URL.escape(import.path)
397
+ URI.encode_uri_path_component(import.path)
399
398
  end
400
399
 
401
400
  def imports_to_native(imports, parent_dir, from_import, url, containing_url)
402
401
  return import_to_native(imports.first, parent_dir, from_import, true) if imports.one?
403
402
 
404
- canonical_url = "#{Protocol::GLOB}?#{URL.escape(url)}##{URL.escape(containing_url)}"
403
+ canonical_url = "#{containing_url}?url=#{URI.encode_uri_query_component(url)}&from_import=#{from_import}"
405
404
  @importer_results[canonical_url] = {
406
405
  contents: imports.flat_map do |import|
407
406
  at_rule = from_import ? '@import' : '@forward'
@@ -565,34 +564,39 @@ module SassC
565
564
  end
566
565
  end
567
566
 
568
- module Protocol
569
- FILE = 'file:'
570
- GLOB = 'sassc-embedded-glob:'
571
- end
572
-
573
- private_constant :Protocol
574
-
575
- module URL
576
- PARSER = URI::Parser.new({ RESERVED: ';/?:@&=+$,' })
577
-
578
- private_constant :PARSER
579
-
567
+ module URI
580
568
  module_function
581
569
 
582
570
  def join(...)
583
- URI.join(...).to_s
571
+ ::URI.join(...).to_s
584
572
  end
585
573
 
586
574
  def parse(str)
587
- PARSER.parse(str)
575
+ ::URI.parse(str)
576
+ end
577
+
578
+ def encode_uri_path_component(str)
579
+ str.b.gsub(%r{[^0-9A-Za-z\-._~!$&'()*+,;=:@/]}n) do |match|
580
+ format('%%%02X', match.unpack1('C'))
581
+ end.force_encoding(str.encoding)
582
+ end
583
+
584
+ def encode_uri_query_component(str)
585
+ str.b.gsub(%r{[^0-9A-Za-z\-._~!$&'()*+,;=:@/?]}n) do |match|
586
+ format('%%%02X', match.unpack1('C'))
587
+ end.force_encoding(str.encoding)
588
588
  end
589
589
 
590
- def escape(str)
591
- PARSER.escape(str)
590
+ def encode_uri_component(str)
591
+ str.b.gsub(/[^0-9A-Za-z\-._~]/n) do |match|
592
+ format('%%%02X', match.unpack1('C'))
593
+ end.force_encoding(str.encoding)
592
594
  end
593
595
 
594
- def unescape(str)
595
- PARSER.unescape(str)
596
+ def decode_uri_component(str)
597
+ str.gsub(/%[0-9A-Fa-f]{2}/) do |match|
598
+ [match[1, 2]].pack('H2')
599
+ end
596
600
  end
597
601
 
598
602
  def file_urls_to_relative_url(url, from_url)
@@ -600,24 +604,24 @@ module SassC
600
604
  end
601
605
 
602
606
  def file_urls_to_relative_path(url, from_url)
603
- unescape(file_urls_to_relative_url(url, from_url))
607
+ decode_uri_component(file_urls_to_relative_url(url, from_url))
604
608
  end
605
609
 
606
610
  def file_url_to_path(url)
607
- return if url.nil?
608
-
609
- path = unescape(parse(url).path)
610
- path = path[1..] if Gem.win_platform? && path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
611
+ path = decode_uri_component(parse(url).path)
612
+ if path.start_with?('/')
613
+ windows_path = path[1..]
614
+ path = windows_path if File.absolute_path?(windows_path)
615
+ end
611
616
  path
612
617
  end
613
618
 
614
619
  def path_to_file_url(path)
615
- return if path.nil?
616
-
617
620
  path = "/#{path}" unless path.start_with?('/')
618
- "file://#{escape(path)}"
621
+
622
+ "file://#{encode_uri_path_component(path)}"
619
623
  end
620
624
  end
621
625
 
622
- private_constant :URL
626
+ private_constant :URI
623
627
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sassc-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.75.2
4
+ version: 1.77.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-13 00:00:00.000000000 Z
11
+ date: 2024-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass-embedded
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.75'
19
+ version: '1.77'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.75'
26
+ version: '1.77'
27
27
  description: An embedded sass shim for SassC.
28
28
  email:
29
29
  - i@ntk.me
@@ -79,7 +79,7 @@ licenses:
79
79
  metadata:
80
80
  bug_tracker_uri: https://github.com/sass-contrib/sassc-embedded-shim-ruby/issues
81
81
  documentation_uri: https://rubydoc.info/gems/sassc
82
- source_code_uri: https://github.com/sass-contrib/sassc-embedded-shim-ruby/tree/v1.75.2
82
+ source_code_uri: https://github.com/sass-contrib/sassc-embedded-shim-ruby/tree/v1.77.0
83
83
  funding_uri: https://github.com/sponsors/ntkme
84
84
  rubygems_mfa_required: 'true'
85
85
  post_install_message:
@@ -91,14 +91,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
- version: 3.1.0
94
+ version: '3.1'
95
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  requirements:
97
97
  - - ">="
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
- rubygems_version: 3.5.3
101
+ rubygems_version: 3.5.11
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Use dart-sass with SassC!