Skip to content

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

@pszczesniak

Description

@pszczesniak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions