Skip to content

[BUGFIX] Handle strings in at-rule preludes - #1650

Merged
oliverklee merged 6 commits into
MyIntervals:mainfrom
sean0407:codex/fix-1625-at-rule-strings
Oct 18, 2026
Merged

oliverklee merged 6 commits into
MyIntervals:mainfrom
sean0407:codex/fix-1625-at-rule-strings

Conversation

@sean0407

@sean0407 sean0407 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem

In a generic at-rule prelude, a quoted string containing { or ; was treated as a parser delimiter. For example, @media (custom: "a;b{c}") { ... } could end the prelude before its actual block and fail to preserve the following stylesheet rules. This addresses #1625.

Change

Scan quoted strings as part of the at-rule arguments, honoring escaped characters before continuing to look for the actual { or ; delimiter. Add a regression test that checks both the parsed at-rule arguments and the rule following the at-rule, and document the fix in the changelog.

Verification

Ran in an isolated PHP 8.5.11 container with no GitHub credentials; network was disconnected during test and static-analysis execution:

  • PHPUnit: 3,031 tests and 4,188 assertions passed.
  • PHP lint, Rector config and dry run, PHPCS, and PHPStan passed.
  • PHP-CS-Fixer was not run because its configured .phive/php-cs-fixer executable is not present in this checkout.

Fixes #1625

@coveralls

coveralls commented Oct 13, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 75.429% (+0.1%) from 75.292% — sean0407:codex/fix-1625-at-rule-strings into MyIntervals:main

@JakeQZ JakeQZ left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sean0407, this looks very good <3.

But I think we need additional testing for the backslash handling, and also suggest using regex for that to make it easier for the reader to follow. (It took me a while to work out what the loop was doing.)

Comment thread CHANGELOG.md Resolved
Comment thread src/CSSList/CSSList.php Resolved
@JakeQZ
JakeQZ self-requested a review October 13, 2026 05:47
@sean0407
sean0407 force-pushed the codex/fix-1625-at-rule-strings branch from e8e2346 to 1bd9468 Compare October 16, 2026 17:25

@JakeQZ JakeQZ left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking excellent now, though I think it would also be good to have a test with a backslash within an argument string but not at the end.

Also, by convention, we put the PR number in the changelog, and newer entries first.

(I was hitherto unaware that \z could be used in a regex as the equivalent of $.)

Comment thread CHANGELOG.md Resolved

@JakeQZ JakeQZ left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now. Thanks @sean0407 for contributing <3.

@oliverklee, do you spot any issues, or is this good to go?

The changelog entry ordering can be adjusted post-PR. We normally only reference the PR number, but I don't see a reason not to reference the bug number as well.

@oliverklee oliverklee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful! Thank you for contributing this, @sean0407! ❤️

Comment thread CHANGELOG.md Resolved
@oliverklee
oliverklee enabled auto-merge (squash) October 18, 2026 10:53
@oliverklee
oliverklee merged commit 1f1eb55 into MyIntervals:main Oct 18, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle strings in at-rules that contain { or ;

4 participants