-
Notifications
You must be signed in to change notification settings - Fork 569
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
A bug of htmlparse #507
Comments
Would you mind just pasting here an example HTML fragment which I couldn't copy anything from your jsbin link because the tab just hangs there. And by "bug" do you mean a crash, an unexpected output, or something else? |
This is var str = "objpicsurl_";
var unnormalAttr = 'ss"123';
var s = '<tag v-ref:vm_pv :imgs=" '+ str +' "></tag>';
var s1 = ' <tag v-ref:vm_pv :imgs=" '+ str +' " '+ unnormalAttr +'></tag>';
var s2 = '<tag v-ref:vm_pv :imgs=" '+ str +' " '+ unnormalAttr +'></tag>';
var startTag = /^<([\w:-]+)((?:\s*[\w:\.-]+(?:\s*(?:(?:=))\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
console.time('not exists unormal HTML tag');
s.match(startTag);
console.timeEnd('not exists unormal HTML tag');
console.log('exists unormal HTML tag and start with a whitespace');
for(var i in str){
console.time(i);
s1.replace(str, str.substring(0, str.length - i)).match(startTag);
console.timeEnd(i);
}
console.log('exists unormal HTML tag and not start with a whitespace');
for(var i in str){
console.time(i);
s2.replace(str, str.substring(0, str.length - i)).match(startTag);
console.timeEnd(i);
}
console.log('If I add a char into str, time increase to about double.'); |
Can you paste the actual HTML content you'd pass to |
Ok. |
|
It is invalid HTML/XML indeed. So I guess the problem here is you'd expect it to error out, but it is taking a long time before it'd do so? |
Yeah, you are right. It is a invalid HTML tag. |
11 chars taste 4300ms, 12 chars taste 8400ms about double. |
Sorry, I type "waste" wrongly to "taste". |
We are on the same page now 👍 I'll take a look at it - thanks for reporting! |
fix submitted in #510 - unfortunately it's on a branch other than |
OK, will see later. Thanks On Thu, Feb 25, 2016, 18:44 Alex Lam S.L. notifications@github.com wrote:
追随 |
I am using version 1.1.1, and there is a bug. I have tested with 1.2.0 version in http://kangax.github.io/html-minifier/ , the same situation took place.
The problem appears at the comment
// Start tag:
of htmlparser.js, specific code ismatch = html.match( startTag );
.Please see here jsbin, but please copy it to someplace with a console.time
The text was updated successfully, but these errors were encountered: