Skip to content

🐛 fix(css): keep escaped hash colors as written - #2191

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

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

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

The CSS minifier could change a hash color that holds a backslash escape. It lower-cased and shortened such a color as if every character were a hex digit, and a stray backslash could then escape the closing brace of the rule. 🎨 Once this merges, such a color keeps its case and is not shortened. Fixes #1849.

The hash-color path no longer lower-cases or shortens a spelling that contains a backslash. It only writes each escape in its shortest form, so #0000\5c becomes #0000\\. The trade-off is that an escaped color is left alone even when a shorter spelling exists.

Behavior changes

  • A hash color whose value contains a backslash keeps its case and its digit count. Before, it was lower-cased, and a color with digit pairs could be shortened.

minify_css shortened and lower-cased a hash color that held a CSS
escape as if every character were a hex digit. The spelled backslash
of an escape could pair up into a digit, and a lone backslash left at
the end escaped the rule's closing brace. A hash with a backslash now
keeps its spelling. Escapes that decode to plain hex digits still
shorten as before.

Fixes tox-dev#1849.
@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 61.1%

2 warnings

⚠️ 1 benchmark with a significant change ran on different hardware

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

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark with a significant change ran in a different software environment

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

See affected benchmarks

⚡ 1 improved benchmark
✅ 581 untouched benchmarks
⏩ 89 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_mutating_feature[path-xpath-one-cold] 143.1 µs 88.8 µs +61.1%

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-1849 (341c7b5) with main (8c70f88)

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 9d6984c into tox-dev:main Nov 15, 2026
31 checks passed
@gaborbernat gaborbernat changed the title fix(css): keep escaped hash colors as written 🐛 fix(css): keep escaped hash colors as written Nov 16, 2026
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 shortens hash colors that hold escapes

1 participant