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

Wrong Css input hangs the CssCommentRegex.Replace #152

Open
horch004 opened this issue Dec 19, 2017 · 0 comments
Open

Wrong Css input hangs the CssCommentRegex.Replace #152

horch004 opened this issue Dec 19, 2017 · 0 comments

Comments

@horch004
Copy link

File: CssParser.cs
Line: 122
Content: string temp = CssCommentRegex.Replace(s, "");

Wrongly formated css somehow hangs up the CssCommentRegex Replace method.
We had someone who linked to a css file which was actually a renamed photoshop file. We don't know what made the Regex hang / stop responding.

We changed the line with the following:

var ts = TimeSpan.FromSeconds(4);
string temp = Regex.Replace(s, @"(?:/\*(.|[\r\n])*?\*/)|(?:(?<!url\s*\([^)]*)//.*)", "", RegexOptions.Compiled, ts);

(added to the top of the file: using System;)

Another approach to safelly MoveCssInline is to run using Task.Run with a timeout.

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