crass 1.0.7 → 1.0.9

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: a90afad390dcbfa666bb15dcc55ff6bc7711a4fabd9e5a920c53783bc22d2c8b
4
- data.tar.gz: ba5fe09c8233f06503da5bf0f89a9c716cb19aa6b867eb6e1bff3f3d7153446d
3
+ metadata.gz: 368a9cc84dabe98dd1d155ac2ae8cbc713183db1a4bcf51a68197c072a68bc42
4
+ data.tar.gz: 3eff45452736d400c5e875257dd009950ede94fa38d8d0714298e9ebb8615473
5
5
  SHA512:
6
- metadata.gz: efc02970ebefe0e0baf624b97c4aa43f9ce95c39acb7c3a8ccd8e5e74d56545bf9ee4efb0b5d67ba4c5e80f1c13563e8fbc1332feea7cd0ac6c207312c57cab4
7
- data.tar.gz: 999316893f90a5f3a7fc9cd48dd20f2f1afd8c3087e772bec065bde19bfe08ad59d7430e786b232bd03f78a3f8054bc79cb4800130cab66ddaf93aff1dcc4a47
6
+ metadata.gz: 96815f33850d81e980fb45a445fac9bf3f9f2e3a6df8796d7dc47fe2c1c2a14a1874b59e7bd646f23b4c36a5bbf6f9774ca045681b8d9272a278ccb0df380e6e
7
+ data.tar.gz: e98d8fbc16e403e1283c5c1d361b5788627ef6f37e342f63925e9b289e0697c078f27d4af48bbec6c0296ca17b8d6f6921ddc39ef5086ae2ebf658f4bfd2d25a
data/HISTORY.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Crass Changelog
2
2
 
3
+ ## 1.0.9 (2026-12-01)
4
+
5
+ ### Security
6
+
7
+ - Moderate: Fixed a tokenizer bug in which, with the `:preserve_hacks` option enabled, a `*` inside a name caused Crass to tokenize CSS differently than a browser would. CSS sanitizers built on Crass that enable `:preserve_hacks` could be tricked into passing through CSS that a browser would then apply. (GHSA-cpc4-vxpc-8mf7)
8
+
9
+ ## 1.0.8 (2026-10-21)
10
+
11
+ ### Security
12
+
13
+ - Moderate: Fixed a tokenizer bug in which a `)` following an escaped backslash (`\\`) inside a bad URL didn't terminate the bad URL token, causing Crass to consume more input than a spec-compliant browser would. CSS sanitizers built on Crass could be tricked into passing through declarations, rules, or at-rules that a browser would then apply. (GHSA-pq4g-8rxf-4g29)
14
+
3
15
  ## 1.0.7 (2026-06-25)
4
16
 
5
17
  ### Security
@@ -89,7 +89,7 @@ module Crass
89
89
 
90
90
  case char.to_sym
91
91
  when :'"'
92
- consume_string
92
+ consume_string(char)
93
93
 
94
94
  when :'#'
95
95
  if @s.peek =~ RE_NAME || valid_escape?(@s.peek(2))
@@ -109,7 +109,7 @@ module Crass
109
109
  end
110
110
 
111
111
  when :"'"
112
- consume_string
112
+ consume_string(char)
113
113
 
114
114
  when :'('
115
115
  create_token(:'(')
@@ -122,9 +122,9 @@ module Crass
122
122
  @s.consume
123
123
  create_token(:substring_match)
124
124
 
125
- # Non-standard: Preserve the IE * hack.
125
+ # Non-standard: Preserve the IE * hack. The `*` is included in the
126
+ # token's raw text but not in its value.
126
127
  elsif @options[:preserve_hacks] && @s.peek =~ RE_NAME_START
127
- @s.reconsume
128
128
  consume_ident
129
129
 
130
130
  else
@@ -132,7 +132,7 @@ module Crass
132
132
  end
133
133
 
134
134
  when :+
135
- if start_number?
135
+ if start_number?(char + @s.peek(2))
136
136
  @s.reconsume
137
137
  consume_numeric
138
138
  else
@@ -161,7 +161,7 @@ module Crass
161
161
  end
162
162
 
163
163
  when :'.'
164
- if start_number?
164
+ if start_number?(char + @s.peek(2))
165
165
  @s.reconsume
166
166
  consume_numeric
167
167
  else
@@ -196,7 +196,7 @@ module Crass
196
196
  create_token(:'[')
197
197
 
198
198
  when :'\\'
199
- if valid_escape?
199
+ if valid_escape?(char + @s.peek)
200
200
  @s.reconsume
201
201
  consume_ident
202
202
  else
@@ -277,9 +277,7 @@ module Crass
277
277
  text = String.new
278
278
 
279
279
  until @s.eos?
280
- if valid_escape?
281
- text << consume_escaped
282
- elsif valid_escape?(@s.peek(2))
280
+ if valid_escape?(@s.peek(2))
283
281
  @s.consume
284
282
  text << consume_escaped
285
283
  else
@@ -320,8 +318,8 @@ module Crass
320
318
  # Consumes an escaped code point and returns its unescaped value.
321
319
  #
322
320
  # This method assumes that the `\` has already been consumed, and that the
323
- # next character in the input has already been verified not to be a newline
324
- # or EOF.
321
+ # next character in the input has already been verified not to be a
322
+ # newline. If the input is at EOF, U+FFFD is returned.
325
323
  #
326
324
  # 4.3.8. https://www.w3.org/TR/2013/WD-css-syntax-3-20130919/#consume-an-escaped-code-point
327
325
  def consume_escaped
@@ -384,13 +382,9 @@ module Crass
384
382
 
385
383
  char = @s.consume
386
384
 
387
- if valid_escape?
385
+ if valid_escape?(char + @s.peek)
388
386
  result << consume_escaped
389
387
 
390
- # Non-standard: IE * hack
391
- elsif char == '*' && @options[:preserve_hacks]
392
- result << @s.consume
393
-
394
388
  else
395
389
  @s.reconsume
396
390
  return result
@@ -567,7 +561,7 @@ module Crass
567
561
  :value => value + consume_bad_url)
568
562
 
569
563
  when '\\'
570
- if valid_escape?
564
+ if valid_escape?(char + @s.peek)
571
565
  value << consume_escaped
572
566
  else
573
567
  # Parse error.
data/lib/crass/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Crass
4
- VERSION = '1.0.7'
4
+ VERSION = '1.0.9'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crass
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Grove
@@ -44,15 +44,9 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
- - ".github/workflows/tests.yml"
48
- - ".gitignore"
49
- - ".yardopts"
50
- - Gemfile
51
47
  - HISTORY.md
52
48
  - LICENSE
53
49
  - README.md
54
- - Rakefile
55
- - crass.gemspec
56
50
  - lib/crass.rb
57
51
  - lib/crass/parser.rb
58
52
  - lib/crass/scanner.rb
@@ -64,10 +58,10 @@ licenses:
64
58
  - MIT
65
59
  metadata:
66
60
  bug_tracker_uri: https://github.com/rgrove/crass/issues
67
- changelog_uri: https://github.com/rgrove/crass/blob/v1.0.7/HISTORY.md
68
- documentation_uri: https://www.rubydoc.info/gems/crass/1.0.7
61
+ changelog_uri: https://github.com/rgrove/crass/blob/v1.0.9/HISTORY.md
62
+ documentation_uri: https://www.rubydoc.info/gems/crass/1.0.9
69
63
  rubygems_mfa_required: 'true'
70
- source_code_uri: https://github.com/rgrove/crass/tree/v1.0.7
64
+ source_code_uri: https://github.com/rgrove/crass/tree/v1.0.9
71
65
  rdoc_options: []
72
66
  require_paths:
73
67
  - lib
@@ -82,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
76
  - !ruby/object:Gem::Version
83
77
  version: '0'
84
78
  requirements: []
85
- rubygems_version: 4.0.10
79
+ rubygems_version: 4.0.20
86
80
  specification_version: 4
87
81
  summary: CSS parser based on the CSS Syntax Level 3 spec.
88
82
  test_files: []
@@ -1,25 +0,0 @@
1
- name: Tests
2
- on: [ push, pull_request ]
3
- jobs:
4
- test:
5
- strategy:
6
- fail-fast: false
7
- matrix:
8
- os:
9
- - ubuntu-latest
10
- - macos-latest
11
- ruby:
12
- - '3.3'
13
- - '3.4'
14
- - jruby
15
- - ruby
16
- - ruby-head
17
- continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
18
- runs-on: ${{ matrix.os }}
19
- steps:
20
- - uses: actions/checkout@v7
21
- - uses: ruby/setup-ruby@9eb537ca036ebaed86729dcb9309076e4c5c3b74 # v1.314.0
22
- with:
23
- bundler-cache: true
24
- ruby-version: ${{ matrix.ruby }}
25
- - run: bundle exec rake
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- .yardoc/
2
- doc/
3
- pkg/
4
- .DS_Store
5
- Gemfile.lock
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --markup markdown
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
data/Rakefile DELETED
@@ -1,21 +0,0 @@
1
- require 'bundler'
2
- require 'rake/testtask'
3
-
4
- Bundler::GemHelper.install_tasks
5
-
6
- Rake::TestTask.new
7
- task :default => [:test]
8
- task :test => :set_rubyopts
9
-
10
- task :set_rubyopts do
11
- ENV['RUBYOPT'] ||= ""
12
- ENV['RUBYOPT'] += " -w"
13
-
14
- if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.3"
15
- ENV['RUBYOPT'] += " --enable-frozen-string-literal --debug=frozen-string-literal"
16
- end
17
- end
18
-
19
- task :'pull-css-tests' do
20
- sh 'git subtree pull -P test/css-parsing-tests https://github.com/SimonSapin/css-parsing-tests.git master --squash'
21
- end
data/crass.gemspec DELETED
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
- require './lib/crass/version'
3
-
4
- Gem::Specification.new do |s|
5
- s.name = 'crass'
6
- s.summary = 'CSS parser based on the CSS Syntax Level 3 spec.'
7
- s.description = 'Crass is a pure Ruby CSS parser based on the CSS Syntax Level 3 spec.'
8
- s.version = Crass::VERSION
9
- s.authors = ['Ryan Grove']
10
- s.email = ['ryan@wonko.com']
11
- s.homepage = 'https://github.com/rgrove/crass/'
12
- s.license = 'MIT'
13
-
14
- s.metadata = {
15
- 'bug_tracker_uri' => 'https://github.com/rgrove/crass/issues',
16
- 'changelog_uri' => "https://github.com/rgrove/crass/blob/v#{s.version}/HISTORY.md",
17
- 'documentation_uri' => "https://www.rubydoc.info/gems/crass/#{s.version}",
18
- 'rubygems_mfa_required' => 'true',
19
- 'source_code_uri' => "https://github.com/rgrove/crass/tree/v#{s.version}",
20
- }
21
-
22
- s.platform = Gem::Platform::RUBY
23
- s.required_ruby_version = Gem::Requirement.new('>= 1.9.2')
24
-
25
- s.require_paths = ['lib']
26
-
27
- s.files = `git ls-files -z`.split("\x0").grep_v(%r{^test/})
28
-
29
- # Development dependencies.
30
- s.add_development_dependency 'minitest', '~> 6.0.6'
31
- s.add_development_dependency 'rake', '~> 13.4.2'
32
- end