r3016 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Jul 24 22:39:05 CEST 2008


Author: phk
Date: 2008-07-24 22:39:04 +0200 (Thu, 24 Jul 2008)
New Revision: 3016

Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
   trunk/varnish-cache/bin/varnishd/heritage.h
   trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Add a check to avoid doing ESI parsing of objects that do not look
like XML.  Our definition of "looks like XML" is that the first
non-white-space character is '<'.

Add a new parameter "esi_syntax" with bits to steer the ESI parser.

Use the first bit to disable the "looks like XML" check.



Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c	2008-07-24 20:16:04 UTC (rev 3015)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_esi.c	2008-07-24 20:39:04 UTC (rev 3016)
@@ -637,6 +637,26 @@
 
 	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
 
+	if (!(params->esi_syntax & 0x00000001)) {
+		/*
+		 * By default, we will not ESI process an object where
+		 *  the first non-space character is different from '<'
+		 */
+		st = VTAILQ_FIRST(&sp->obj->store);
+		AN(st);
+		for (u = 0; u < st->len; u++) {
+			if (isspace(st->ptr[u]))
+				continue;
+			if (st->ptr[u] == '<')
+				break;
+			WSP(sp, SLT_ESI_xmlerror,
+			    "No ESI processing, "
+			    "binary object: 0x%02x at pos %u.",
+			    st->ptr[u], u);
+			return;
+		}
+	}
+
 	/* XXX: only if GET ? */
 	ew = eww;
 	memset(eww, 0, sizeof eww);

Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h	2008-07-24 20:16:04 UTC (rev 3015)
+++ trunk/varnish-cache/bin/varnishd/heritage.h	2008-07-24 20:39:04 UTC (rev 3016)
@@ -143,6 +143,9 @@
 	/* Maximum esi:include depth allowed */
 	unsigned		max_esi_includes;
 
+	/* ESI parser hints */
+	unsigned		esi_syntax;
+
 	/* Rush exponent */
 	unsigned		rush_exponent;
 

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-07-24 20:16:04 UTC (rev 3015)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-07-24 20:39:04 UTC (rev 3016)
@@ -719,6 +719,13 @@
 		"the backend, so don't increase thoughtlessly.\n",
 		0,
 		"4", "restarts" },
+	{ "esi_syntax",
+		tweak_uint, &master.esi_syntax, 0, UINT_MAX,
+		"Bitmap controlling ESI parsing code:\n"
+		"  0x00000001 - Don't check if it looks like XML\n"
+		"Use 0x notation and do the bitor in your head :-)\n",
+		0,
+		"0", "restarts" },
 	{ "max_esi_includes",
 		tweak_uint, &master.max_esi_includes, 0, UINT_MAX,
 		"Maximum depth of esi:include processing."




More information about the varnish-commit mailing list