]> err.no Git - varnish/commitdiff
Add a check to avoid doing ESI parsing of objects that do not look
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 24 Jul 2008 20:39:04 +0000 (20:39 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 24 Jul 2008 20:39:04 +0000 (20:39 +0000)
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.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3016 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_vrt_esi.c
varnish-cache/bin/varnishd/heritage.h
varnish-cache/bin/varnishd/mgt_param.c

index 315bd3946ae7f266dab7c1cb2dee8600c0bc13df..e5da1fc557eba238c846a44f7473c59b2285470a 100644 (file)
@@ -637,6 +637,26 @@ VRT_ESI(struct sess *sp)
 
        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);
index 767ac8c793f0d196b5b11c03035f540d95612d4a..e98920cf021dae5a9c3d3583a5501c79a337d421 100644 (file)
@@ -143,6 +143,9 @@ struct params {
        /* Maximum esi:include depth allowed */
        unsigned                max_esi_includes;
 
+       /* ESI parser hints */
+       unsigned                esi_syntax;
+
        /* Rush exponent */
        unsigned                rush_exponent;
 
index d1f29e84b9b5a3f6efbfd859ee4f20cbdd6a8045..f0bd5323d01de5874e1b5455a421b298e12abd2c 100644 (file)
@@ -719,6 +719,13 @@ static const struct parspec parspec[] = {
                "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."