Commit e2dbf214 authored by Guillaume Quintard's avatar Guillaume Quintard Committed by Dridi Boukelmoune

[ncsa] -j will escape control characters

parent 84e99267
......@@ -572,7 +572,7 @@ addf_vsl(enum VSL_tag_e tag, long i, const char *prefix)
ALLOC_OBJ(w, VSL_WATCH_MAGIC);
AN(w);
if (VSL_tagflags[tag])
if (VSL_tagflags[tag] && CTX.quote_how != VSB_QUOTE_JSON)
VUT_Error(vut, 1, "Tag %s can contain control characters",
VSL_tags[tag]);
w->tag = tag;
......@@ -921,7 +921,6 @@ process_vsl(const struct vsl_watch_head *head, enum VSL_tag_e tag,
{
struct vsl_watch *w;
const char *p;
VTAILQ_FOREACH(w, head, list) {
CHECK_OBJ_NOTNULL(w, VSL_WATCH_MAGIC);
if (tag != w->tag)
......@@ -966,13 +965,16 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[],
skip = 0;
while (skip == 0 && 1 == VSL_Next(t->c)) {
tag = VSL_TAG(t->c->rec.ptr);
if (VSL_tagflags[tag])
if (VSL_tagflags[tag] &&
CTX.quote_how != VSB_QUOTE_JSON)
continue;
b = VSL_CDATA(t->c->rec.ptr);
e = b + VSL_LEN(t->c->rec.ptr);
while (e > b && e[-1] == '\0')
e--;
if (!VSL_tagflags[tag]) {
while (e > b && e[-1] == '\0')
e--;
}
switch (tag) {
case SLT_HttpGarbage:
......
varnishtest "SLT_Debug can be printed by varnishncsa -j"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
import cookie;
sub vcl_recv {
cookie.parse("");
}
} -start
varnish v1 -cliok "param.show vsl_mask +Debug"
client c1 {
txreq
rxresp
} -run
# Let's fist create a script to reduce in all the variants below.
shell {
varnishncsa -d -n ${v1_name} -F '%{VSL:Debug}x' -j | grep "^cookie: nothing to parse\\\\u0000"
}
shell -err -expect "Tag Debug can contain control characters" {
varnishncsa -d -n ${v1_name} -F '%{VSL:Debug}x'
}
......@@ -57,6 +57,8 @@ Varnish Cache 7.x.x (2021-09-15)
* ACLs default to `pedantic` which is now a per-ACL feature flag.
* `varnishncsa -j` will now accept to print fields with control characters.
================================
Varnish Cache 6.6.0 (2021-03-15)
================================
......
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