镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Open

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.

Activity

  1. monarosej commented on Jan 20, 2025

    @monarosej

    All modern browsers support the following 140 color names (click on a color name, or a hex value, to view the color as the background-color along with different text colors):

    Image
    Image
    Image
    Image
    Image
    Image
    Image
    Image
    Image
    Image
    Image

  2. holblin commented on May 27, 2025

    @holblin

    Hi @pszczesniak , did you try to use https://github.com/adobe/css-tools ?
    I did some changes in the regex and improved the parsing in a couple of cases...
    It might not work, but if you open an issue there, I will take a look at some point (please be patient though).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions