Skip to content

Commit 4c2ed79

Browse files
author
ArthurHub
committed
* fix html comment handling
1 parent 0d36a84 commit 4c2ed79

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Source/HtmlRenderer/Parse/HtmlParser.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,18 @@ public static CssBox ParseDocument(string source)
4444

4545
if (source[tagIdx + 1] == '!')
4646
{
47-
// skip the html crap elements (<!-- bla -->) (<!crap bla>)
48-
startIdx = source.IndexOf(">", tagIdx + 2);
49-
endIdx = startIdx > 0 ? startIdx + 1 : tagIdx + 2;
47+
if( source[tagIdx + 2] == '-' )
48+
{
49+
// skip the html comment elements (<!-- bla -->)
50+
startIdx = source.IndexOf("-->", tagIdx + 2);
51+
endIdx = startIdx > 0 ? startIdx + 3 : tagIdx + 2;
52+
}
53+
else
54+
{
55+
// skip the html crap elements (<!crap bla>)
56+
startIdx = source.IndexOf(">", tagIdx + 2);
57+
endIdx = startIdx > 0 ? startIdx + 1 : tagIdx + 2;
58+
}
5059
}
5160
else
5261
{

0 commit comments

Comments
 (0)