[3.0] 3cd1a4e Fix a bug in the entity-replacement code in the ESI-parser.

Tollef Fog Heen tfheen at varnish-cache.org
Wed Aug 17 11:25:33 CEST 2011


commit 3cd1a4e93d6ab319f26c1d03e332fa2022127a24
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jul 18 14:25:00 2011 +0000

    Fix a bug in the entity-replacement code in the ESI-parser.
    
    Patch by:	scoof
    Fixes		#961

diff --git a/bin/varnishd/cache_esi_parse.c b/bin/varnishd/cache_esi_parse.c
index 411db43..afef1fb 100644
--- a/bin/varnishd/cache_esi_parse.c
+++ b/bin/varnishd/cache_esi_parse.c
@@ -518,7 +518,7 @@ vep_do_include(struct vep_state *vep, enum dowhat what)
 #define R(w,f,r)							\
 			if (q + w <= p + l && !memcmp(q, f, w)) { \
 				VSB_printf(vep->vsb, "%c", r);	\
-				q += l;				\
+				q += w;				\
 				continue;			\
 			}
 			R(6, "'", '\'');
diff --git a/bin/varnishtest/tests/r00961.vtc b/bin/varnishtest/tests/r00961.vtc
new file mode 100644
index 0000000..b162379
--- /dev/null
+++ b/bin/varnishtest/tests/r00961.vtc
@@ -0,0 +1,49 @@
+varnishtest "Test XML 1.0 entity references"
+
+server s1 {
+	rxreq
+	expect req.url == "/"
+	txresp -body {
+		<esi:include src="t&t"/>
+		<esi:include src="t<t"/>
+		<esi:include src="t>t"/>
+		<esi:include src="t't"/>
+		<esi:include src="t"t"/>
+	}
+
+	rxreq
+	expect req.url == "/t&t"
+	txresp -body "1"
+
+	rxreq
+	expect req.url == "/t<t"
+	txresp -body "22"
+
+	rxreq
+	expect req.url == "/t>t"
+	txresp -body "333"
+
+	rxreq
+	expect req.url == {/t't}
+	txresp -body "4444"
+
+	rxreq
+	expect req.url == {/t"t}
+	txresp -body "55555"
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_recv {
+		return (pass);
+	}
+	sub vcl_fetch {
+		set beresp.do_esi = true;
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 200
+	expect resp.bodylen == 32
+} -run



More information about the varnish-commit mailing list