From 18b7021299e23758af39fbdef90482b59f079fe5 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 7 Mar 2010 03:22:31 +1300 Subject: [PATCH] Author: Henrik Nordstrom Improve coding style of digest parser somewhat so it's easier to follow --- src/auth/digest/auth_digest.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index ce1c9cf96a..2e33f07940 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -1125,17 +1125,29 @@ AuthDigestConfig::decode(char const *proxy_auth) String temp(proxy_auth); while (strListGetItem(&temp, ',', &item, &ilen, &pos)) { - String value; + /* isolate directive name & value */ size_t nlen; - /* isolate directive name */ + size_t vlen; if ((p = (const char *)memchr(item, '=', ilen)) && (p - item < ilen)) { nlen = p++ - item; - if (!httpHeaderParseQuotedString(p, &value)) - value.limitInit(p, ilen - (p - item)); - } else + vlen = ilen - (p - item); + } else { nlen = ilen; + vlen = 0; + } - if (!value.defined()) { + /* parse value. auth-param = token "=" ( token | quoted-string ) */ + String value; + if (vlen > 0) { + if (*p == '"') { + if (!httpHeaderParseQuotedString(p, &value)) { + debugs(29, 9, "authDigestDecodeAuth: Failed to parse attribute '" << temp << "' in '" << proxy_auth << "'"); + continue; + } + } else { + value.limitInit(p, vlen); + } + } else { debugs(29, 9, "authDigestDecodeAuth: Failed to parse attribute '" << temp << "' in '" << proxy_auth << "'"); continue; } -- 2.47.3