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
merged 1 commit into from
Jul 26, 2018

Conversation

westonruter
Copy link
Member

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: MyIntervals/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 July 25, 2018 20:37
@westonruter westonruter force-pushed the fix/css-selectors-with-commas branch from d3ef392 to f1fdc8f Compare July 25, 2018 20:42
@westonruter westonruter force-pushed the fix/css-selectors-with-commas branch from f1fdc8f to c0cf592 Compare July 25, 2018 20:57
Copy link
Member

@amedina amedina left a comment

Choose a reason for hiding this comment

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

LGTM. Shipt it!

@westonruter westonruter merged commit 80ed7f0 into develop Jul 26, 2018
@westonruter westonruter deleted the fix/css-selectors-with-commas branch July 26, 2018 01:16
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