[master] 896aa8d Fix regex matches in some esoteric cases

Federico G. Schwindt fgsch at lodoss.net
Mon Sep 12 12:35:14 CEST 2016


commit 896aa8dcbc163fe029b6827284891fe6d80a1ea2
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Mon Sep 12 10:00:50 2016 +0100

    Fix regex matches in some esoteric cases
    
    E.g. set req.http.foo = req.http.foo + req.http.bar ~ "foobar"

diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc
index a932426..cd0ab28 100644
--- a/bin/varnishtest/tests/v00020.vtc
+++ b/bin/varnishtest/tests/v00020.vtc
@@ -120,10 +120,8 @@ varnish v1 -vcl {
 		set req.http.foo = 3.0 * 2;
 		set req.http.foo = 3.0 / 2;
 
-		set req.http.foo = req.http.foo ~ "bar";
-		set req.http.foo = req.http.foo !~ "bar";
-		set req.http.foo = "foo" ~ "bar";
-		set req.http.foo = "foo" !~ "bar";
+		set req.http.foo = req.http.foo + "bar" ~ "bar";
+		set req.http.foo = req.http.foo + "bar" !~ "bar";
 
 		set req.ttl = 1s;
 	}
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 415c584..3e0feef 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -1147,6 +1147,8 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, vcc_type_t fmt)
 	}
 	if (((*e)->fmt == STRING || (*e)->fmt == STRING_LIST) &&
 	    (tl->t->tok == '~' || tl->t->tok == T_NOMATCH)) {
+		if ((*e)->fmt == STRING_LIST)
+			vcc_expr_tostring(tl, e, STRING);
 		not = tl->t->tok == '~' ? "" : "!";
 		vcc_NextToken(tl);
 		ExpectErr(tl, CSTR);



More information about the varnish-commit mailing list