No-nest mode for script content in HTML parser MP-486
[metaproxy-moved-to-github.git] / src / test_html_parser.cpp
index 370ff72..dd66b57 100644 (file)
@@ -70,7 +70,7 @@ public:
         out.append(value, len);
     }
 };
-
+#if 0
 BOOST_AUTO_TEST_CASE( test_html_parser_1 )
 {
     try
@@ -187,7 +187,7 @@ BOOST_AUTO_TEST_CASE( test_html_parser_4 )
         mp::HTMLParser hp;
         const char* html =
             "<?xml version=\"1.0\" strandalone=\"no\"?  ax>\n"
-            "<book><x ? href/></book>";
+            "<book><x ? href/><!-- hello > --></book>";
 
         const char* expected = html;
         MyEvent e;
@@ -241,6 +241,66 @@ BOOST_AUTO_TEST_CASE( test_html_parser_5 )
     }
 }
 
+BOOST_AUTO_TEST_CASE( test_html_parser_6 )
+{
+    try
+    {
+        mp::HTMLParser hp;
+        const char* html =
+            "<html><script><x;</script></html>";
+
+        const char* expected = html;
+        MyEvent e;
+        hp.set_verbose(0);
+        hp.parse(e, html);
+
+        BOOST_CHECK_EQUAL(std::string(expected), e.out);
+        if (std::string(expected) != e.out)
+        {
+            std::cout << "Expected" << std::endl;
+            std::cout << expected << std::endl;
+            std::cout << "Got" << std::endl;
+            std::cout << e.out << std::endl;
+        }
+    }
+    catch (std::exception & e)
+    {
+        std::cout << e.what();
+        std::cout << std::endl;
+        BOOST_CHECK (false);
+    }
+}
+#endif
+BOOST_AUTO_TEST_CASE( test_html_parser_7 )
+{
+    try
+    {
+        mp::HTMLParser hp;
+        const char* html =
+            "<html><script>x=1; for (i=0;i<x;i++) ;\nx=2;\n</script></html>";
+
+        const char* expected = html;
+        MyEvent e;
+        hp.set_verbose(1);
+        hp.parse(e, html);
+
+        BOOST_CHECK_EQUAL(std::string(expected), e.out);
+        if (std::string(expected) != e.out)
+        {
+            std::cout << "Expected" << std::endl;
+            std::cout << expected << std::endl;
+            std::cout << "Got" << std::endl;
+            std::cout << e.out << std::endl;
+        }
+    }
+    catch (std::exception & e)
+    {
+        std::cout << e.what();
+        std::cout << std::endl;
+        BOOST_CHECK (false);
+    }
+}
+
 
 /*
  * Local variables: