[master] varnish-3.0.0-beta1-84-g76fc17c
Poul-Henning Kamp
phk at varnish-cache.org
Fri May 27 22:22:45 CEST 2011
commit 76fc17c1852e2a1cb29f4e49a32009a93bb45972
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri May 27 20:22:15 2011 +0000
Make sure that the arguments we pass regsub() came out as strings.
Fixes #921
diff --git a/bin/varnishtest/tests/r00921.vtc b/bin/varnishtest/tests/r00921.vtc
new file mode 100644
index 0000000..d3e643d
--- /dev/null
+++ b/bin/varnishtest/tests/r00921.vtc
@@ -0,0 +1,21 @@
+varnishtest "VCC type issue in regsub arg 1"
+
+server s1 {
+ rxreq
+ expect req.http.foo == "127.0.0.1"
+ expect req.http.bar == "127.0.0.1"
+ txresp
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_recv {
+ set req.http.bar = regsub(req.url, ".*", client.ip);
+ set req.http.foo = regsub(client.ip, ":.*", client.ip);
+ }
+} -start
+
+client c1 {
+ txreq -url "/"
+ rxresp
+ expect resp.status == 200
+} -run
diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c
index 43e6ee1..8774d8d 100644
--- a/lib/libvcl/vcc_expr.c
+++ b/lib/libvcl/vcc_expr.c
@@ -454,6 +454,8 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, const struct symbol *sym)
SkipToken(tl, '(');
vcc_expr0(tl, &e2, STRING);
+ if (e2->fmt != STRING)
+ vcc_expr_tostring(&e2, STRING);
SkipToken(tl, ',');
ExpectErr(tl, CSTR);
@@ -465,6 +467,8 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, const struct symbol *sym)
SkipToken(tl, ',');
vcc_expr0(tl, &e2, STRING);
+ if (e2->fmt != STRING)
+ vcc_expr_tostring(&e2, STRING);
*e = vcc_expr_edit(STRING, "\v1, \v2)", *e, e2);
SkipToken(tl, ')');
}
More information about the varnish-commit
mailing list