Commit e6193fb4 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Support dquote-delimited fields in VSL records

When we output a VSL field containing spaces, all bets are off for VSL
queries relying on that field or subsequent fields in the same record.
The solution is to allow a quoted-string format for such fields.
parent 5ff94556
varnishtest "VSL quoted fields"
varnish v1 -vcl {
import std;
backend be none;
sub vcl_recv {
# a series of 3-fields log records
std.log({" custom log "ok" "});
std.log({" "valid" "fields" ok "});
std.log({" "missing""blank" ko "});
std.log({" missing dquote "ko "});
# "
return (synth(200));
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
} -run
# records with malformed fields don't show up
shell -expect "2" {
varnishlog -d -n ${v1_name} -g raw -q 'VCL_Log[3]' | wc -l
}
......@@ -122,7 +122,7 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
double lhs_float = 0.;
const char *b, *e, *q;
char *p;
int i;
int i, dq;
AN(vex);
AN(rec);
......@@ -144,15 +144,40 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec)
/* Field */
if (vex->lhs->field > 0) {
for (e = b, i = 0; *e && i < vex->lhs->field; i++) {
for (e = b, i = 0, dq = 0; *e && i < vex->lhs->field; i++) {
/* Skip end of previous field */
if (dq) {
assert(e > b);
assert(*e == '"');
dq = 0;
e++;
if (*e == '\0')
break;
if (!isspace(*e))
return (0);
}
b = e;
/* Skip ws */
while (*b && isspace(*b))
b++;
dq = (*b == '"');
if (dq)
b++;
e = b;
/* Skip non-ws */
while (*e && !isspace(*e))
e++;
if (dq) {
/* Find end of string */
while (*e && *e != '"')
e++;
if (*e != '"')
return (0);
} else {
/* Skip non-ws */
while (*e && !isspace(*e))
e++;
}
}
assert(b <= e);
if (*b == '\0' || i < vex->lhs->field)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment