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

Problem parsing :is() #211

Closed
christophe-ledu opened this issue Oct 10, 2023 · 3 comments · Fixed by #249
Closed

Problem parsing :is() #211

christophe-ledu opened this issue Oct 10, 2023 · 3 comments · Fixed by #249
Labels
enhancement New feature or request

Comments

@christophe-ledu
Copy link

Expected Behaviour

The content of the :is() is a selector itself ( https://developer.mozilla.org/en-US/docs/Web/CSS/:is )

Actual Behaviour

Currently, parsing selector as in the following code split the selector with the , which doesn't work

Reproduce Scenario (including but not limited to)

Using a :is() with a , inside the parenthesis

Steps to Reproduce

Platform and Version

Linux, Node 18

Sample Code that illustrates the problem

import {parse} from "@adobe/css-tools";
console.dir(await parse('.klass:is(:nth-child(1), :nth-child(2)) {margin: 0 !important}'), { depth: 4 });

Logs taken while reproducing problem

yarn node test.js
{
  type: 'stylesheet',
  stylesheet: {
    source: undefined,
    rules: [
      {
        type: 'rule',
        selectors: [ '.klass:is(:nth-child(1)', ':nth-child(2))' ],
        declarations: [ [Object] ],
        position: $0865a9fb4cc365fe$export$2e2bcd8739ae039 {
          start: [Object],
          end: [Object],
          source: ''
        }
      }
    ],
    parsingErrors: []
  }
}
@holblin holblin added the enhancement New feature or request label Oct 18, 2023
@holblin
Copy link

holblin commented Nov 28, 2023

Hi @christophe-ledu ,
Thanks for that report. A fix is on the way and will be released very soon.
This was linked to nested parenthesis which weren't taken into account for selectors.
Thanks for your patience.

@holblin holblin mentioned this issue Nov 30, 2023
@holblin
Copy link

holblin commented Nov 30, 2023

Note: this will be fixed with 1 level only.

@holblin
Copy link

holblin commented Nov 30, 2023

Please ignore my previous message. To prevent another ReDos I found a better implementation that will handle all the depth of parentheses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants