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

Regex issue with javascript line comments #47

Open
qoreycube opened this issue Jan 12, 2018 · 1 comment
Open

Regex issue with javascript line comments #47

qoreycube opened this issue Jan 12, 2018 · 1 comment

Comments

@qoreycube
Copy link

Line 161 in StreamReaderExtension.cs:
htmlContents = Regex.Replace(htmlContents, @"// (.*?)\r?\n", "", RegexOptions.Singleline);

This catches regex expressions in javascripts that have escaped forward slashes. For example:
url += $('#field').val().replace(///g, '').replace(/&/g, 'and').substring(0, 50) + '/';

the regex expression "///g" is valid, but not a comment.

Trying to think of a workaround for this line, but my regex is a little rusty.

I was thinking this:
htmlContents = Regex.Replace(htmlContents, @"[^\\]// (.*?)\r?\n", "", RegexOptions.Singleline);

But that also fails.

@qoreycube
Copy link
Author

Actually, I correct myself. I think it might be here.

javaScriptComments = javaScriptComments.Replace(scriptBlock, Regex.Replace(scriptBlock, @"[^:|""|']//(.*?)\r?\n", ""));

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