]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Henrik Nordstrom <henrik@henriknordstrom.net>
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 6 Mar 2010 14:22:31 +0000 (03:22 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 6 Mar 2010 14:22:31 +0000 (03:22 +1300)
Improve coding style of digest parser somewhat so it's easier to follow

src/auth/digest/auth_digest.cc

index ce1c9cf96afa1eeac24696da6e606768ed574de0..2e33f07940fc48acb8b1f650260ca094cf4fea22 100644 (file)
@@ -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;
         }