]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Improve coding style of digest parser somewhat so it's easier to follow
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Sat, 6 Mar 2010 12:56:14 +0000 (13:56 +0100)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Sat, 6 Mar 2010 12:56:14 +0000 (13:56 +0100)
src/auth/digest/auth_digest.cc

index 823645c6d3aff17b3b877a1252e00f37b78f95ee..ff6fa09d2cd61c76773035c031e325272656819e 100644 (file)
@@ -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;
         }