[master] 98afc23 Whitespace after colon is optional
Federico G. Schwindt
fgsch at lodoss.net
Sun Nov 27 22:33:05 CET 2016
commit 98afc234c6dd07710830125a8e6cec8014b0ae72
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Sun Nov 27 21:21:05 2016 +0000
Whitespace after colon is optional
Fixes #2148.
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 994a255..2fa8ed3 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -803,12 +803,12 @@ static int
isprefix(const char *str, const char *prefix, const char *end,
const char **next)
{
+ size_t len;
- while (str < end && *str && *prefix &&
- tolower((int)*str) == tolower((int)*prefix))
- ++str, ++prefix;
- if (*str && *str != ' ')
+ len = strlen(prefix);
+ if (end - str < len || strncasecmp(str, prefix, len))
return (0);
+ str += len;
if (next) {
while (str < end && *str && *str == ' ')
++str;
@@ -1010,7 +1010,7 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[],
if (isprefix(b, "Host:", e, &p))
frag_line(0, p, e, &CTX.frag[F_host]);
else if (isprefix(b, "Authorization:", e, &p) &&
- isprefix(p, "basic", e, &p))
+ isprefix(p, "basic ", e, &p))
frag_line(0, p, e, &CTX.frag[F_auth]);
break;
case (SLT_VCL_call + BACKEND_MARKER):
diff --git a/bin/varnishtest/tests/r02148.vtc b/bin/varnishtest/tests/r02148.vtc
new file mode 100644
index 0000000..9654b39
--- /dev/null
+++ b/bin/varnishtest/tests/r02148.vtc
@@ -0,0 +1,18 @@
+varnishtest "Whitespace after colon is optional"
+
+server s1 {
+ rxreq
+ txresp
+} -start
+
+varnish v1 -vcl+backend {} -start
+
+client c1 {
+ txreq -hdr "Host:qux" -hdr "Authorization:Basic Zm9vOmJhcg=="
+ rxresp
+} -run
+
+process p1 {varnishncsa -d -n ${v1_name} -F "%u %{Host}i"} -run
+shell {grep -q "foo qux" ${tmpdir}/p1/stdout}
+process p2 {varnishncsa -d -n ${v1_name} -F "%r"} -run
+shell {grep -q "GET http://qux/ HTTP/1.1" ${tmpdir}/p2/stdout}
More information about the varnish-commit
mailing list