r3210 - in trunk/varnish-cache/bin: varnishd varnishtest/tests

phk at projects.linpro.no phk at projects.linpro.no
Sun Sep 21 09:36:06 CEST 2008


Author: phk
Date: 2008-09-21 09:36:05 +0200 (Sun, 21 Sep 2008)
New Revision: 3210

Added:
   trunk/varnish-cache/bin/varnishtest/tests/e00010.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
   trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Add the feature requested in #266:  ignore non-esi tags entirely.



Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c	2008-09-21 07:30:56 UTC (rev 3209)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c	2008-09-21 07:36:05 UTC (rev 3210)
@@ -466,6 +466,17 @@
 			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;

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-09-21 07:30:56 UTC (rev 3209)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-09-21 07:36:05 UTC (rev 3210)
@@ -726,6 +726,7 @@
 		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" },

Added: trunk/varnish-cache/bin/varnishtest/tests/e00010.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/e00010.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/e00010.vtc	2008-09-21 07:36:05 UTC (rev 3210)
@@ -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




More information about the varnish-commit mailing list