[4.1] 152dd84 Handle whitespace after floats in test fields

Lasse Karstensen lkarsten at varnish-software.com
Fri Jan 22 16:46:59 CET 2016


commit 152dd84ad66717e2b248d57840cf6c26269d3648
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Fri Jan 22 12:00:53 2016 +0000

    Handle whitespace after floats in test fields
    
    Broken in 9bb8f96223d248beb5962961b493b16dcc8ecc2a.
    Committed solution proposed by phk@, discussed with phk@ and martin at .
    
    Fixes #1845.

diff --git a/bin/varnishtest/tests/l00001.vtc b/bin/varnishtest/tests/l00001.vtc
index b1ec63c..bcd4391 100644
--- a/bin/varnishtest/tests/l00001.vtc
+++ b/bin/varnishtest/tests/l00001.vtc
@@ -151,6 +151,12 @@ logexpect l1 -d 1 -g vxid -q "RespHeader[2] == 123" {
 	  expect * =	End
 } -run
 
+# Test field on floats
+logexpect l1 -d 1 -g vxid -q "RespHeader[2] == 123." {
+	  expect 0 *	Begin	req
+	  expect * =	End
+} -run
+
 # Test taglists
 logexpect l1 -d 1 -g vxid -q "Debug,Resp* == 200" {
 	  expect 0 *	Begin	req
diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c
index 1ad6811..60cc54d 100644
--- a/lib/libvarnishapi/vsl_query.c
+++ b/lib/libvarnishapi/vsl_query.c
@@ -78,7 +78,7 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
 	const struct vex_rhs *rhs;
 	long long lhs_int = 0;
 	double lhs_float = 0.;
-	const char *b, *e;
+	const char *b, *e, *q;
 	char *p;
 	int i;
 
@@ -145,9 +145,11 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
 			/* Can't parse - no match */
 			return (0);
 		case VEX_FLOAT:
-			lhs_float = VNUM(b);
+			lhs_float = VNUMpfx(b, &q);
 			if (isnan(lhs_float))
 				return (0);
+			if (q != NULL && q > p && !isspace(q[-1]))
+				return (0);
 			break;
 		default:
 			WRONG("Wrong RHS type");



More information about the varnish-commit mailing list