http_rewrite: fix start anchor (^) match
[metaproxy-moved-to-github.git] / src / test_filter_rewrite.cpp
index 65cb4c0..3749509 100644 (file)
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 )
             "<?xml version='1.0'?>\n"
             "<filter xmlns='http://indexdata.com/metaproxy'\n"
             "        id='rewrite1' type='http_rewrite'>\n"
-            " <request>\n"
+            " <request verbose=\"1\">\n"
             "   <rule name=\"null\"/>\n"
             "   <rule name=\"url\">\n"
             "     <rewrite from='"
@@ -81,16 +81,19 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 )
             "  <within header=\"link\" rule=\"null\"/>\n"
             "  <within reqline=\"1\" rule=\"url\"/>\n"
             " </request>\n"
-            " <response>\n"
+            " <response verbose=\"1\">\n"
             "   <rule name=\"null\"/>\n"
             "   <rule name=\"url\">\n"
+            "     <rewrite from='foo' to='bar'/>\n"
+            "     <rewrite from='^cx' to='cy'/>\n"
             "     <rewrite from='"
     "(?&lt;proto>https?://)(?&lt;host>[^/?# &quot;&apos;>]+)/(?&lt;path>[^  &quot;&apos;>]+)'\n"
             "            to='${proto}${pxhost}/${pxpath}/${host}/${path}' />\n"
             "  </rule>\n"
             "  <within header=\"link\" rule=\"url\"/>\n"
-            "  <within tag=\"script\" attr=\"src,#text\" rule=\"url\"/>\n"
-            "  <within tag=\"style\" rule=\"url\"/>\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"
             " </response>\n"
             "</filter>\n"
@@ -132,7 +135,9 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 )
             "}"
             "</style>"
             "</head>"
-            "<script>var jslink=\"http://targetsite/webservice.xml\";</script>"
+            "<script>var jslink=\"http://targetsite/webservice.xml\";"
+            "var some=foo;"
+            "</script>"
             "<body>"
             "<p>Welcome to our website. It doesn't make it easy to get pro"
             "xified"
@@ -141,11 +146,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 \" />"
             "</body></html>";
 
         const char *resp_expected =
             "HTTP/1.1 200 OK\r\n"
-            "Content-Length: 522\r\n"
+            "Content-Length: 564\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,15 +164,19 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 )
             "}"
             "</style>"
             "</head>"
-            "<script>var jslink=\"http://proxyhost/proxypath/targetsite/webservice.xml\";</script>"
+            "<script>var jslink=\"http://proxyhost/proxypath/targetsite/webservice.xml\";"
+            "var some=bar;"
+            "</script>"
             "<body>"
             "<p>Welcome to our website. It doesn't make it easy to get pro"
             "xified"
             "<a href=\"http://proxyhost/proxypath/targetsite/page2.html\">"
             "  An absolute link</a>"
-            "<a target=\"_blank\" href=\"http://proxyhost/proxypath/targetsite/page3.html\">"
+            "<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 \"/>"
             "</body></html>";
 
         int r;