From 78e8b324f4f697cb84ac67debafc747f6fa82bda Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 21 Sep 2008 07:36:05 +0000 Subject: [PATCH] Add the feature requested in #266: ignore non-esi tags entirely. 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 | 11 ++++++++ varnish-cache/bin/varnishd/mgt_param.c | 1 + .../bin/varnishtest/tests/e00010.vtc | 27 +++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 varnish-cache/bin/varnishtest/tests/e00010.vtc diff --git a/varnish-cache/bin/varnishd/cache_vrt_esi.c b/varnish-cache/bin/varnishd/cache_vrt_esi.c index 0f0f148f..181b55b7 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_esi.c +++ b/varnish-cache/bin/varnishd/cache_vrt_esi.c @@ -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, " 5 ? 5 : i) && + memcmp(p, " 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; diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index 6175badd..3a080886 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -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 index 00000000..66c98b19 --- /dev/null +++ b/varnish-cache/bin/varnishtest/tests/e00010.vtc @@ -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 { + + bar + + 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 -- 2.39.5