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

Declaration matcher by regular expression is finishing too early. #178

Open
pszczesniak opened this issue Feb 22, 2024 · 0 comments
Open

Comments

@pszczesniak
Copy link

During parsing large CSS codebase i've noticed that in a specific case an error is thrown:

missing '}'

to be more precise: below is an example of something that breaks it:

div {
	background-image:url("data:image/svg+xml;utf8,<svg width='120' height='12' xmlns='http://www.w3.org/2000/svg' ><text style='paint-order:stroke fill; clip-path: inset(-3px);' stroke-width='13' fill='black' x='3' y='7' font-size='9px' font-family='Consolas, monospace'>TEST</text></svg>");
}

👇

style='paint-order:stroke fill; clip-path: inset(-3px);'

To be precise - the last semicolon.

Problem lies in the regular expression:

var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);

It ends before that semicolon which i mentioned above, here is an example:

https://regex101.com/r/NBh8Cy/1

Simplest solution is to remove that semicolon, but i won't have that ability always.

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

1 participant