header and attr are regex. Case insensitive compare
[metaproxy-moved-to-github.git] / src / test_filter_rewrite.cpp
index 00065a4..68acc0f 100644 (file)
@@ -80,9 +80,10 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 )
             "  </content>\n"
             "  <content type=\"html\" mime=\"text/xml|text/html\">\n"
             "    <within tag=\"body\" attr=\"background\" rule=\"null\"/>\n"
-            "    <within tag=\"script\" attr=\"#text\" rule=\"url\"/>\n"
+            "    <within tag=\"script\" attr=\"#text\" type=\"quoted-literal\" rule=\"url\"/>\n"
             "    <within tag=\"style\" attr=\"#text\" rule=\"url\"/>\n"
-            "    <within attr=\"href,src\" rule=\"url\"/>\n"
+            "    <within attr=\"href|src\" rule=\"url\"/>\n"
+            "    <within attr=\"onclick\" type=\"quoted-literal\" rule=\"url\"/>\n"
             "  </content>\n"
             "  <content type=\"quoted-literal\" mime=\".*javascript\">\n"
             "    <within rule=\"url\"/>\n"
@@ -115,7 +116,6 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 )
 
         const char *resp_buf =
             "HTTP/1.1 200 OK\r\n"
-            "Content-Length: 441\r\n"
             "Content-Type: text/html\r\n"
             "Link: <http://targetsite/file.xml>; rel=absolute\r\n"
             "Link: </dir/file.xml>; rel=relative\r\n"
@@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 )
             "</style>"
             "</head>"
             "<script>var jslink=\"http://targetsite/webservice.xml\";"
-            "var some=foo;"
+            "var some=\"foo\"; foo=1;"
             "</script>"
             "<body>"
             "<p>Welcome to our website. It doesn't make it easy to get pro"
@@ -138,13 +138,13 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 )
             "<a target=_blank href=\"http://targetsite/page3.html\">"
             "  Another abs link</a>"
             "<a href=\"/docs/page4.html\" />"
-            "<a href=\"cxcx\" />"
-            "<a href=\"cx \" />"
+            "<A href=\"cxcx\" />"
+            "<a HREF=\"cx \" onclick=\"foo(&quot;foo&quot;);\"/>"
             "</body></html>";
 
         const char *resp_expected =
             "HTTP/1.1 200 OK\r\n"
-            "Content-Length: 564\r\n"
+            "Content-Length: 605\r\n"
             "Content-Type: text/html\r\n"
             "Link: <http://proxyhost/proxypath/targetsite/file.xml>; rel=absolute\r\n"
             "Link: </dir/file.xml>; rel=relative\r\n"
@@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 )
             "</style>"
             "</head>"
             "<script>var jslink=\"http://proxyhost/proxypath/targetsite/webservice.xml\";"
-            "var some=bar;"
+            "var some=\"bar\"; foo=1;"
             "</script>"
             "<body>"
             "<p>Welcome to our website. It doesn't make it easy to get pro"
@@ -167,8 +167,8 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 )
             "<a target=_blank href=\"http://proxyhost/proxypath/targetsite/page3.html\">"
             "  Another abs link</a>"
             "<a href=\"/docs/page4.html\"/>"
-            "<a href=\"cycx\"/>"
-            "<a href=\"cy \"/>"
+            "<A href=\"cycx\"/>"
+            "<a HREF=\"cy \" onclick=\"foo(&quot;bar&quot;);\"/>"
             "</body></html>";
 
         Z_GDU *gdu_res;
@@ -264,12 +264,6 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_2 )
             "  <content type=\"headers\">\n"
             "    <within header=\"link\" rule=\"url\"/>\n"
             "  </content>\n"
-            "  <content type=\"html\" mime=\"text/xml|text/html\">\n"
-            "    <within tag=\"body\" attr=\"background\" rule=\"null\"/>\n"
-            "    <within tag=\"script\" attr=\"#text\" rule=\"url\"/>\n"
-            "    <within tag=\"style\" attr=\"#text\" rule=\"url\"/>\n"
-            "    <within attr=\"href,src\" rule=\"url\"/>\n"
-            "  </content>\n"
             "  <content type=\"quoted-literal\" mime=\".*javascript\">\n"
             "    <within rule=\"url\"/>\n"
             "  </content>\n"
@@ -301,7 +295,6 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_2 )
 
         const char *resp_buf =
             "HTTP/1.1 200 OK\r\n"
-            "Content-Length: 140\r\n"
             "Content-Type: application/javascript\r\n"
             "Link: <http://targetsite/file.xml>; rel=absolute\r\n"
             "Link: </dir/file.xml>; rel=relative\r\n"