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 in comment regex, fix in issue description #367

Open
AbstractionsAs opened this issue Sep 28, 2023 · 1 comment
Open

Bug in comment regex, fix in issue description #367

AbstractionsAs opened this issue Sep 28, 2023 · 1 comment

Comments

@AbstractionsAs
Copy link

Hi,

There's a bug in the comment regex in the CSS parser, but it's easily fixed.

Imagine the following CSS:

img.logo {
  -premailer-src: "https://example.com/logo.png";
  -premailer-height: 80px;
  -premailer-width: 100px;
  width: 100px;
  height: 100px;
}

This is stripped by the comment regex and turns into a long string with all the values.

If the regex (?:/\*(.|[\r\n])*?\*/)|(?:(?<!url\s*\([^)]*)//.*) is changed to (?:/\*(.|[\r\n])*?\*/)|(?:(?<!url\s*\([^)]*)(?<!\:)//.*) in CssParser.cs, // sequences that are immediatly preceded by : will not be matched, and everything will work

@jasekiw
Copy link
Collaborator

jasekiw commented Oct 20, 2023

HI @AbstractionsAs ,

This will fix this case. However you can do a protocol agnostic url which this will not catch. ex.

 -premailer-src: "//example.com/logo.png";

I think the regex should probably be replaced by a parser for better context. However we might be able to get away with a pretty clever regex expression.

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

2 participants