Skip to content
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

Fix parsing CSS selectors which contain commas #1286

merged 1 commit into from Jul 26, 2018


None yet
2 participants
Copy link

commented Jul 25, 2018

I found an issue where a CSS selectors would fail to parse correctly when they contain commas. For example:

.widget:not(.widget_text, .jetpack_widget_social_icons) ul {
    list-style: none;
    margin: 0;
    padding: 0;

There should only be one selector here: .widget:not(.widget_text, .jetpack_widget_social_icons) ul. Instead, the parser incorrectly extracts two:

  • .widget:not(.widget_text
  • .jetpack_widget_social_icons) ul

The fix is to add placeholders for expressions contained in parentheses or brackets prior to splitting, and then replace the placeholders with their original values on the split selectors.

This PR updates the PHP-CSS-Parser to the state of the library with this upstream PR merged: sabberworm/PHP-CSS-Parser#138

This PR also fixes a PHPCS complaint regarding preg_quote() not having an explicit $delimiter set.

@westonruter westonruter added this to the v1.0 milestone Jul 25, 2018

@westonruter westonruter requested a review from amedina Jul 25, 2018

@westonruter westonruter force-pushed the fix/css-selectors-with-commas branch from d3ef392 to f1fdc8f Jul 25, 2018

@westonruter westonruter force-pushed the fix/css-selectors-with-commas branch from f1fdc8f to c0cf592 Jul 25, 2018

Copy link

left a comment

LGTM. Shipt it!

@westonruter westonruter merged commit 80ed7f0 into develop Jul 26, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed

@westonruter westonruter deleted the fix/css-selectors-with-commas branch Jul 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.