]> err.no Git - varnish/commitdiff
Add the feature requested in #266: ignore non-esi tags entirely.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 21 Sep 2008 07:36:05 +0000 (07:36 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 21 Sep 2008 07:36:05 +0000 (07:36 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3210 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_vrt_esi.c
varnish-cache/bin/varnishd/mgt_param.c
varnish-cache/bin/varnishtest/tests/e00010.vtc [new file with mode: 0644]

index 0f0f148fd63967a06a36ffe22c2e761cf1f66661..181b55b7315a8d49301fb7655548776d43170d3f 100644 (file)
@@ -466,6 +466,17 @@ esi_parse2(struct esi_work *ew)
                        continue;
                } 
 
+               /* Ignore non esi elements, if so instructed */
+               if ((params->esi_syntax & 0x02)) {
+                       if (memcmp(p, "<esi:", i > 5 ? 5 : i) &&
+                           memcmp(p, "</esi:", i > 6 ? 6 : i)) {
+                               p += 1;
+                               continue;
+                       }
+                       if (i < 6)
+                               return (p);
+               }
+
                /* Find end of this element */
                for (q = p + 1; q < t.e && *q != '>'; q++)
                        continue;
index 6175badd230cf291464320e532fe2ae640847c3e..3a080886b2a92557f931ec967a6f9c866923a0c3 100644 (file)
@@ -726,6 +726,7 @@ static const struct parspec parspec[] = {
                tweak_uint, &master.esi_syntax, 0, UINT_MAX,
                "Bitmap controlling ESI parsing code:\n"
                "  0x00000001 - Don't check if it looks like XML\n"
+               "  0x00000002 - Ignore non-esi elements\n"
                "Use 0x notation and do the bitor in your head :-)\n",
                0,
                "0", "bitmap" },
diff --git a/varnish-cache/bin/varnishtest/tests/e00010.vtc b/varnish-cache/bin/varnishtest/tests/e00010.vtc
new file mode 100644 (file)
index 0000000..66c98b1
--- /dev/null
@@ -0,0 +1,27 @@
+# $Id: e00008.vtc 3012 2008-07-24 12:22:35Z des $
+
+test "Ignoring non esi elements"
+
+server s1 {
+       rxreq 
+       txresp -body {
+               <f<esi?
+               <esi:remove>
+                       bar
+               </esi:remove>
+               foo
+       }
+} -start
+
+varnish v1 -vcl+backend {
+       sub vcl_fetch {
+               esi;
+       }
+} -start -cli "param.set esi_syntax 2"
+
+client c1 {
+       txreq 
+       rxresp
+       expect resp.status == 200
+       expect resp.bodylen == 21
+} -run