Commit dc8f079c authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

vmod_cookie: Avoid generating a trailing semi-colon

The separator between cookies in a cookie header is "; " and we should
not generate it in a way that adds a spurious ';' at the end of the
cookie list.

Refs #3754
parent 872ca00d
......@@ -18,5 +18,5 @@ varnish v1 -vcl {
client c1 {
txreq -url "/"
rxresp
expect resp.http.X-foo == "cookie1=cookie1value; cookie3=cookie3value; cookie4=cookie4value;"
expect resp.http.X-foo == "cookie1=cookie1value; cookie3=cookie3value; cookie4=cookie4value"
} -run
......@@ -16,6 +16,6 @@ varnish v1 -vcl {
client c1 {
txreq
rxresp
expect resp.http.X-foo == "cookie1=cookie1BAD;"
expect resp.http.X-foo == "cookie1=cookie1BAD"
expect resp.http.X-bar == ""
} -run
......@@ -13,7 +13,7 @@ varnish v1 -vcl {
set resp.http.X-foo = cookie.get_string();
# Test exotic admin-supplied filter strings.
cookie.parse("bredela=eggwhites; empire=jellytots;");
cookie.parse("bredela=eggwhites; empire=jellytots");
cookie.keep(",,,,bredela, ,empire,baz,");
set resp.http.X-bar = cookie.get_string();
......@@ -25,7 +25,7 @@ varnish v1 -vcl {
client c1 {
txreq -url "/"
rxresp
expect resp.http.X-foo == "bredela=eggwhites; empire=jellytots;"
expect resp.http.X-bar == "bredela=eggwhites; empire=jellytots;"
expect resp.http.X-foo == "bredela=eggwhites; empire=jellytots"
expect resp.http.X-bar == "bredela=eggwhites; empire=jellytots"
expect resp.http.X-baz == ""
} -run
......@@ -13,11 +13,11 @@ varnish v1 -vcl {
set resp.http.X-foo = cookie.get_string();
# Test exotic admin-supplied filter strings.
cookie.parse("bredela=eggwhites; empire=jellytots;");
cookie.parse("bredela=eggwhites; empire=jellytots");
cookie.filter(",,,,bredela, ,baz,");
set resp.http.X-bar = cookie.get_string();
cookie.parse("foo=bar; bar=baz;");
cookie.parse("foo=bar; bar=baz");
cookie.filter(req.http.none);
set resp.http.X-baz = cookie.get_string();
}
......@@ -26,7 +26,7 @@ varnish v1 -vcl {
client c1 {
txreq -url "/"
rxresp
expect resp.http.X-foo == "biscuit=standard; chocolatechip=verychippy;"
expect resp.http.X-bar == "empire=jellytots;"
expect resp.http.X-baz == "foo=bar; bar=baz;"
expect resp.http.X-foo == "biscuit=standard; chocolatechip=verychippy"
expect resp.http.X-bar == "empire=jellytots"
expect resp.http.X-baz == "foo=bar; bar=baz"
} -run
This diff is collapsed.
......@@ -14,13 +14,13 @@ varnish v1 -vcl {
client c1 {
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
} -run
client c2 {
txreq -hdr "Cookie: __utmc=253898641; __utma=253898641.654622101.1372224466.1372224466.1372224466.1; __utmb=253898641.44.10.1372224466; __utmz=253898641.1372224466.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=index%2Bof%2Bccnp%2Bpdf"
rxresp
expect resp.http.X-foo == "__utmc=253898641; __utma=253898641.654622101.1372224466.1372224466.1372224466.1; __utmb=253898641.44.10.1372224466; __utmz=253898641.1372224466.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=index%2Bof%2Bccnp%2Bpdf;"
expect resp.http.X-foo == "__utmc=253898641; __utma=253898641.654622101.1372224466.1372224466.1372224466.1; __utmb=253898641.44.10.1372224466; __utmz=253898641.1372224466.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=index%2Bof%2Bccnp%2Bpdf"
} -run
client c3 {
......@@ -40,12 +40,12 @@ client c4 {
client c5 {
txreq -hdr "Cookie: cookie1=foobarbaz"
rxresp
expect resp.http.X-foo == "cookie1=foobarbaz;"
expect resp.http.X-foo == "cookie1=foobarbaz"
} -run
# Don't overflow the buffer with an edge case
client c6 {
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128a;=" -hdr "X-Not-Cookie: sessionid=a707505310ddf259bb290d3ca63fc561"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128a;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128a"
} -run
......@@ -27,7 +27,7 @@ client c1 {
expect resp.http.X-foo == resp.http.X-bar
expect resp.http.X-baz != resp.http.X-foo
expect resp.http.X-baz == "biscuit=standard; empire=jellytots;"
expect resp.http.X-baz == "biscuit=standard; empire=jellytots"
expect resp.http.X-qux == ""
} -run
......@@ -9,7 +9,7 @@ varnish v1 -vcl {
cookie.keep_re("NOTHING_MATCHES_SO_NOTHING_KEPT$");
set resp.http.X-empty = cookie.get_string();
cookie.parse("biscuit=standard; bredela=eggwhites; empire=jellytots;");
cookie.parse("biscuit=standard; bredela=eggwhites; empire=jellytots");
cookie.keep_re("^b");
set resp.http.X-bees = cookie.get_string();
}
......@@ -19,5 +19,5 @@ client c1 {
txreq -url "/"
rxresp
expect resp.http.X-empty == ""
expect resp.http.X-bees == "biscuit=standard; bredela=eggwhites;"
expect resp.http.X-bees == "biscuit=standard; bredela=eggwhites"
} -run
......@@ -13,43 +13,43 @@ varnish v1 -vcl {
client c1 {
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
}
......@@ -57,43 +57,43 @@ client c1 {
client c2 {
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
txreq -hdr "Cookie: csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
rxresp
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560;"
expect resp.http.X-foo == "csrftoken=0e0c3616e41a6bd561b72b7f5fc1128f; sessionid=a707505310ddf259bb290d3ca63fc560"
}
......
......@@ -441,8 +441,8 @@ vmod_get_string(VRT_CTX, struct vmod_priv *priv)
CHECK_OBJ_NOTNULL(curr, VMOD_COOKIE_ENTRY_MAGIC);
AN(curr->name);
AN(curr->value);
VSB_printf(output, "%s%s=%s;", sep, curr->name, curr->value);
sep = " ";
VSB_printf(output, "%s%s=%s", sep, curr->name, curr->value);
sep = "; ";
}
res = WS_VSB_finish(output, ctx->ws, NULL);
if (res == NULL)
......
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