From: Henrik Nordstrom Date: Sat, 6 Mar 2010 12:56:14 +0000 (+0100) Subject: Improve coding style of digest parser somewhat so it's easier to follow X-Git-Tag: SQUID_3_2_0_1~383 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=df604ac03792e8f04c086fd24049efdb5ba370a2;p=thirdparty%2Fsquid.git Improve coding style of digest parser somewhat so it's easier to follow --- diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index 823645c6d3..ff6fa09d2c 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -1121,17 +1121,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; }