From: Adam Dickmeiss Date: Tue, 10 Sep 2013 12:18:54 +0000 (+0200) Subject: Careful check of termination X-Git-Tag: v1.3.62~4 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=489bd9188aed44d93c29f996311e0477152d592a;p=metaproxy-moved-to-github.git Careful check of termination --- diff --git a/src/html_parser.cpp b/src/html_parser.cpp index 1a403d4..3f1a4f4 100644 --- a/src/html_parser.cpp +++ b/src/html_parser.cpp @@ -270,11 +270,13 @@ void mp::HTMLParser::Rep::parse_str(HTMLParserEvent &event, const char *cp) if (!nest) { if (i == 6 && !yaz_strncasecmp(cp, "script", i)) - nest = true; - else { - continue; + int ws = skipSpace(cp + 6); + if (cp[ws + 6] == '>') + nest = true; /* really terminated */ } + if (!nest) + continue; } tagText(event, text_start, cp - 2); event.closeTag(cp, i); diff --git a/src/test_html_parser.cpp b/src/test_html_parser.cpp index dd66b57..2b23dde 100644 --- a/src/test_html_parser.cpp +++ b/src/test_html_parser.cpp @@ -70,7 +70,7 @@ public: out.append(value, len); } }; -#if 0 + BOOST_AUTO_TEST_CASE( test_html_parser_1 ) { try @@ -270,18 +270,20 @@ BOOST_AUTO_TEST_CASE( test_html_parser_6 ) BOOST_CHECK (false); } } -#endif + BOOST_AUTO_TEST_CASE( test_html_parser_7 ) { try { mp::HTMLParser hp; const char* html = - ""; + "" + "\nx=2;\n"; const char* expected = html; MyEvent e; - hp.set_verbose(1); + hp.set_verbose(0); hp.parse(e, html); BOOST_CHECK_EQUAL(std::string(expected), e.out);