[master] e8ea815 Handle string literal concatenation correctly.

Poul-Henning Kamp phk at FreeBSD.org
Tue May 22 14:28:09 UTC 2018


commit e8ea8155b2d58ed4b2848dee164a0898c610f19f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue May 22 14:27:13 2018 +0000

    Handle string literal concatenation correctly.
    
    Fixes #2685

diff --git a/bin/varnishtest/tests/c00068.vtc b/bin/varnishtest/tests/c00068.vtc
index 88a47b6..5fb3b48 100644
--- a/bin/varnishtest/tests/c00068.vtc
+++ b/bin/varnishtest/tests/c00068.vtc
@@ -10,6 +10,8 @@ server s1 {
 } -start
 
 varnish v1 -vcl+backend {
+	import std;
+
 	sub vcl_backend_response {
 		if (bereq.url == "/333") {
 			set beresp.status = 333;
@@ -18,7 +20,7 @@ varnish v1 -vcl+backend {
 	}
 	sub vcl_deliver {
 		if (req.url == "/332") {
-			return (synth(332, "FOO"));
+			return (synth(332, "F" + "OO" + std.tolower("FOO")));
 		} else if (req.url == "/333") {
 			return (synth(resp.status + 1000,
 				resp.reason));
@@ -64,6 +66,7 @@ client c2 {
 	txreq -url /332
 	rxresp
 	expect resp.status == 332
+	expect resp.reason == "FOOfoo"
 	expect resp.http.restarts == 1
 	expect resp.bodylen == 1
 } -run
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 37bfb04..e5ef674 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -920,6 +920,7 @@ vcc_expr_add(struct vcc *tl, struct expr **e, vcc_type_t fmt)
 				*e = vcc_expr_edit(tl, STRINGS,
 				    "\v1\n\v2", *e, e2);
 				(*e)->constant = EXPR_CONST;
+				(*e)->nstr = 1;
 				if (lit)
 					(*e)->constant |= EXPR_STR_CONST;
 			} else {
@@ -1297,6 +1298,8 @@ vcc_Expr(struct vcc *tl, vcc_type_t fmt)
 	assert(fmt != STRINGS);
 	vcc_expr0(tl, &e, fmt);
 	ERRCHK(tl);
+	assert(e->fmt == fmt);
+
 	vcc_expr_fmt(tl->fb, tl->indent, e);
 	VSB_printf(tl->fb, "\n");
 	vcc_delete_expr(e);


More information about the varnish-commit mailing list