Skip to content
Browse files

Fix a VCL expression type error: TIME +/- DURATION should return TIME

Fixes	#1211

Thanks to:	Federico G. Schwindt
  • Loading branch information...
1 parent 968d11d commit cc513fdc6cc098fcdc378af6ec80959a5c744054 @bsdphk bsdphk committed Oct 11, 2012
Showing with 25 additions and 0 deletions.
  1. +22 −0 bin/varnishtest/tests/r01211.vtc
  2. +3 −0 lib/libvcl/vcc_expr.c
View
22 bin/varnishtest/tests/r01211.vtc
@@ -0,0 +1,22 @@
+varnishtest "TIME +/- DURATION -> TIME"
+
+server s1 {
+ rxreq
+ txresp
+} -start
+
+varnish v1 -vcl+backend {
+
+ sub vcl_deliver {
+ set resp.http.bar = now + 4 d;
+ set resp.http.foo = now - 4 d;
+ }
+
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.http.bar ~ "..., .. ... 20[1-9][0-9] ..:..:.. GMT"
+ expect resp.http.foo ~ "..., .. ... 20[1-9][0-9] ..:..:.. GMT"
+} -run
View
3 lib/libvcl/vcc_expr.c
@@ -847,6 +847,9 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt)
ERRCHK(tl);
if (tk->tok == '-' && (*e)->fmt == TIME && e2->fmt == TIME) {
/* OK */
+ } else if ((*e)->fmt == TIME && e2->fmt == DURATION) {
+ f2 = TIME;
+ /* OK */
} else if (tk->tok == '-' &&
(*e)->fmt == BYTES && e2->fmt == BYTES) {
/* OK */

0 comments on commit cc513fd

Please sign in to comment.
Something went wrong with that request. Please try again.