litespeedtech / litespeedtech/lscache_wp
CSS calc requires spaces around asterisks, /minifier.cls.php is removing them
- Dominant language
- PHP
- Stars
- 257
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
The CSS minifier is removing spaces around asterisks, but CSS calc() requires spaces around asterisks (and all other operators)
### Example input CSS
```
.element {
margin-bottom: calc(-1 * var(--grid-row-gap));
}
```
Now lines 547 and 550 of https://github.com/litespeedtech/lscache_wp/blob/master/lib/css-min/minifier.cls.php
appear to cause an issue
```
// Remove spaces before the things that should not have spaces before them.
$body = preg_replace('/ ([:=,)*\/;\n])/S', '$1', $body);
// Remove the spaces after the things that should not have spaces after them.
$body = preg_replace('/([:=,(*\/!;\n]) /S', '$1', $body);
```
### RESULT
CSS output
```
.element {
margin-bottom: calc(-1*var(--grid-row-gap));
}
```
An illegal / non functional CSS calc (calc requires spaces around operations)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in lib/css-min/minifier.cls.php at lines 547 and 550, then reproduce the issue with the calc() example from the report. Verify that minification preserves the spaces required around calc() operators, and confirm the output remains valid and functional CSS.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100