Skip to content

Fix AtRuleParser to correctly parse at-rule names without trailing braces #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 24, 2025

Problem

The AtRuleParser.getAtRuleName() method incorrectly included trailing { characters in at-rule names when there was no space before the opening brace. This caused validation errors for valid CSS at-rules.

Before:

@font-face{           → parsed as "font-face{"@media screen{        → parsed as "media"       ❌ (but affected value parsing)

After:

@font-face{           → parsed as "font-face"@media screen{        → parsed as "media"       ✅ (with correct value "screen")

Solution

Updated the getAtRuleName() method to remove trailing { characters using the existing removeEndingString() utility method. This ensures consistent parsing regardless of spacing before the opening brace.

Changes:

  • Modified src/CssLint/Tokenizer/Parser/AtRuleParser.php to strip trailing { from at-rule names
  • Added comprehensive test cases covering edge cases without spaces before braces
  • Verified existing functionality remains intact

Testing

  • ✅ All existing tests continue to pass (117/117)
  • ✅ Added 3 new test cases for at-rules without spaces before braces
  • ✅ Validated with complete CSS strings containing @font-face rules
  • ✅ Confirmed @font-face properties (font-display, src, unicode-range) are correctly defined in referential

Impact

This fix resolves validation errors for properly formatted CSS at-rules, particularly @font-face declarations, improving the linter's accuracy and reducing false positives.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Masterminds/html5-php/zipball/f5ac2c0b0a2eefca70b2ce32a5809992227e75a6
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/bovigo/vfsStream/zipball/fe695ec993e0a55c3abdda10a9364eb31c6f1bf0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/guzzle/guzzle/zipball/7b2f29fe81dc4da0ca0ea7d42107a0845946ea77
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/krakjoe/pcov-clobber/zipball/4c30759e912e6e5d5bf833fb3d77b5bd51709f05
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/nikic/PHP-Parser/zipball/715f4d25e225bc47b293a8b997fe6ce99bf987d2
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/SlkxPN /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/SlkxPN /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov (http block)
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/symfony/console/zipball/7d29659bc3c9d8e9a34e2c3414ef9e9e003e6cf3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/symfony/css-selector/zipball/cb23e97813c5837a041b73a6d63a9ddff0778f5e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/symfony/dom-crawler/zipball/19073e3e0bb50cbc1cb286077069b3107085206f
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • https://api.github.com/repos/symfony/string/zipball/f3570b8c61ca887a9e2938e85cb6458515d2b125
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/jokzpz /usr/bin/composer install --no-progress --ignore-platform-req=ext-pcov --no-interaction (http block)
  • www.w3.org
    • Triggering command: php scripts/css-referential-scraper (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@neilime neilime closed this Jun 24, 2025
@Copilot Copilot AI changed the title [WIP] Fix AtRuleParser.getAtRuleName() to Correctly Parse At-Rule Names Fix AtRuleParser to correctly parse at-rule names without trailing braces Jun 24, 2025
@Copilot Copilot AI requested a review from neilime June 24, 2025 09:38
Copilot finished work on behalf of neilime June 24, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants