From 489bd9188aed44d93c29f996311e0477152d592a Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 10 Sep 2013 14:18:54 +0200 Subject: [PATCH] Careful check of termination --- src/html_parser.cpp | 8 +++++--- src/test_html_parser.cpp | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) 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); -- 1.7.10.4