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

[BUG] It stuck in an infinite loop when parsing specific css. #390

Open
greg-md opened this issue Nov 24, 2021 · 2 comments
Open

[BUG] It stuck in an infinite loop when parsing specific css. #390

greg-md opened this issue Nov 24, 2021 · 2 comments

Comments

@greg-md
Copy link

greg-md commented Nov 24, 2021

If you run this, you will never get a response.

const juice = require('juice');
const result = juice(`<style>.my-class:not(.is-content-justification-space-between, .is-content-justification-right) {}</style>`);
console.log('result', result);

If there is only one class inside the :not(...), or if the class names are shorter - it could not be reproduced.

Node version: v10.24.1
Juice version: 8.0.0

@filoscoder
Copy link

I think this will solve it
#442

@sparga
Copy link

sparga commented Apr 6, 2023

I recently encountered this as well and I believe it's because of an issue with mensch, the library used to transform CSS into tokens.
Selectors are split with split(',') which in this situation creates a token like :not(.is-content-justification-space-between with no closing parenthesis.

When this token is passed to the Slick parser, it blocks at this line as the Regex evaluation seems to never completes.

There is a PR open to fix this in mensch (brettstimmerman/mensch#29) but it uses a pattern with negative lookbehind which is not supported on all browsers.

If it helps, here is a test case to reproduce this issue:

.css file:

#root [mstyles='flowchart_container'] :is([mstyles~='flowchart_block_simple'],[mstyles~='flowchart_block_multi'],[mstyles~='flowchart_block_dashed'],[mstyles~='flowchart_icon_container']) {
	background: var(--background);
	border-color: var(--on-background);
}

.html file:

<div id="root"></div>

.out file:

<div id="root"></div>

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

No branches or pull requests

3 participants