]> err.no Git - varnish/commitdiff
Fix #326: Don't emit zerolength verbatim strings before esi:include
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 21 Sep 2008 06:49:38 +0000 (06:49 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 21 Sep 2008 06:49:38 +0000 (06:49 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3208 d4fa192b-c00b-0410-8231-f00ffab90ce4

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

index 62df74fac966100c66922c297406c03a596f6ac1..0f0f148fd63967a06a36ffe22c2e761cf1f66661 100644 (file)
@@ -790,9 +790,11 @@ ESI_Deliver(struct sess *sp)
        struct object *obj;
 
        VTAILQ_FOREACH(eb, &sp->obj->esibits, list) {
-               WRK_Write(sp->wrk, eb->chunk_length, -1);
-               WRK_Write(sp->wrk, eb->verbatim.b, Tlen(eb->verbatim));
-               WRK_Write(sp->wrk, "\r\n", -1);
+               if (Tlen(eb->verbatim)) {
+                       WRK_Write(sp->wrk, eb->chunk_length, -1);
+                       WRK_Write(sp->wrk, eb->verbatim.b, Tlen(eb->verbatim));
+                       WRK_Write(sp->wrk, "\r\n", -1);
+               }
                if (eb->include.b == NULL ||
                    sp->esis >= params->max_esi_includes)
                        continue;
diff --git a/varnish-cache/bin/varnishtest/tests/r00326.vtc b/varnish-cache/bin/varnishtest/tests/r00326.vtc
new file mode 100644 (file)
index 0000000..0927a65
--- /dev/null
@@ -0,0 +1,23 @@
+# $Id: e00008.vtc 3012 2008-07-24 12:22:35Z des $
+
+test "No zerolength verbatim before <esi:include...>"
+
+server s1 {
+       rxreq 
+       txresp -body {<esi:include src="/foo"/><esi:include src="/foo"/>}
+       rxreq 
+       txresp -body "FOO\n"
+} -start
+
+varnish v1 -vcl+backend {
+       sub vcl_fetch {
+               esi;
+       }
+} -start
+
+client c1 {
+       txreq 
+       rxresp
+       expect resp.status == 200
+       expect resp.bodylen == 8
+} -run