From: Adam Dickmeiss Date: Mon, 8 Jul 2013 13:23:49 +0000 (+0200) Subject: More appropriate HTML comment handling X-Git-Tag: v1.3.59~9 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=b8f4ac1af9456465a24ecd338fd998e292030abf;p=metaproxy-moved-to-github.git More appropriate HTML comment handling --- diff --git a/src/html_parser.cpp b/src/html_parser.cpp index 22d4a31..a720c56 100644 --- a/src/html_parser.cpp +++ b/src/html_parser.cpp @@ -222,9 +222,22 @@ void mp::HTMLParser::Rep::parse_str(HTMLParserEvent &event, const char *cp) { int i; tagText(event, text_start, cp - 1); - for (i = 1; cp[i] && cp[i] != '>'; i++) - ; - event.openTagStart(cp, i); + if (cp[1] == '-' && cp[2] == '-') + { + for (i = 3; cp[i]; i++) + if (cp[i] == '-' && cp[i+1] == '-' && cp[i+2] == '>') + { + i+= 2; + event.openTagStart(cp, i); + break; + } + } + else + { + for (i = 1; cp[i] && cp[i] != '>'; i++) + ; + event.openTagStart(cp, i); + } if (m_verbose) printf("------ dtd %.*s\n", i, cp); i += tagEnd(event, cp, i, cp + i); diff --git a/src/test_html_parser.cpp b/src/test_html_parser.cpp index 370ff72..3604436 100644 --- a/src/test_html_parser.cpp +++ b/src/test_html_parser.cpp @@ -187,7 +187,7 @@ BOOST_AUTO_TEST_CASE( test_html_parser_4 ) mp::HTMLParser hp; const char* html = "\n" - ""; + ""; const char* expected = html; MyEvent e;