Skip to content

🐛 fix(css): keep three-colon selectors as written - #2200

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:sec-fix/issue-1851
Nov 15, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:sec-fix/issue-1851

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Minifying a selector with three or more colons in a row could remove one colon, and a second pass changed it again. The shortening of legacy pseudo-elements (::name to :name, which the legacy single-colon pseudo-elements allow) also fired on a colon that touched another colon, so :::before lost a colon and could turn a rule that browsers ignore into one that applies. 🎯 Once this merges, such a run stays as written. Fixes #1851.

The minifier shortens a legacy pseudo-element only when its :: stands alone, so selectors without a run of three or more colons are unchanged.

Behavior changes

  • A selector with a run of three or more colons is kept as written. Before, the minifier removed one colon from the run.

The legacy pseudo-element shortening dropped a colon from a run of three
or more colons. The selector became a valid pseudo-element, so the output
changed again on a second pass. Such a run now stays as written, and the
shortening applies only to a pair that is not part of a longer run.

Fixes tox-dev#1851
@gaborbernat gaborbernat added the bug Something isn't working label Nov 15, 2026
@codspeed

codspeed Bot commented Nov 15, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 11.02%

2 warnings

⚠️ 3 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 3 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

⚡ 3 improved benchmarks
✅ 579 untouched benchmarks
⏩ 89 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_mutating_feature[path-xpath-one-cold] 107.1 µs 89 µs +20.44%
⚡ test_feature[query-closest] 256.1 µs 237.6 µs +7.79%
⚡ test_feature[select-nth] 462.8 µs 439 µs +5.41%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing gaborbernat:sec-fix/issue-1851 (7377bc5) with main (efd4b6a)

Open in CodSpeed

Footnotes

  1. 89 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@gaborbernat
gaborbernat merged commit bbac256 into tox-dev:main Nov 15, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minify_css rewrites ::: pseudo selectors differently on each pass

1 participant