]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
2003-05-21 01:51 hno
authorhno <>
Fri, 20 Jun 2003 01:02:33 +0000 (01:02 +0000)
committerhno <>
Fri, 20 Jun 2003 01:02:33 +0000 (01:02 +0000)
Bug #644: strListGetItem() failed to account for quoting, causing digest
authentication to fail on URLs with comma and possibly other odd HTTP
parsing errors.

src/HttpHeaderTools.cc

index d343d8761d42998b4a894b21b58442c82ecc845f..be7d77a650dbf3e04bfa88e8e60fb8316193db86 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeaderTools.cc,v 1.41 2003/03/10 04:56:36 robertc Exp $
+ * $Id: HttpHeaderTools.cc,v 1.42 2003/06/19 19:02:33 hno Exp $
  *
  * DEBUG: section 66    HTTP Header Tools
  * AUTHOR: Alex Rousskov
@@ -261,8 +261,14 @@ int
 strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos)
 {
     size_t len;
+    static char delim[2][3] = {
+                                  { '"', '?', 0},
+                                  { '"', '\\', 0}};
+    int quoted = 0;
     assert(str && item && pos);
 
+    delim[0][1] = del;
+
     if (*pos) {
         if (!**pos)            /* end of string */
             return 0;
@@ -281,10 +287,24 @@ strListGetItem(const String * str, char del, const char **item, int *ilen, const
     *item = *pos;              /* remember item's start */
 
     /* find next delimiter */
-    *pos = strchr(*item, del);
+    do {
+        *pos += strcspn(*pos, delim[quoted]);
+
+        if (**pos == del)
+            break;
+
+        if (**pos == '"') {
+            quoted = !quoted;
+            *pos += 1;
+        }
+
+        if (quoted && **pos == '\\') {
+            *pos += 1;
 
-    if (!*pos)                 /* last item */
-        *pos = *item + strlen(*item);
+            if (**pos)
+                *pos += 1;
+        }
+    } while (**pos);
 
     len = *pos - *item;                /* *pos points to del or '\0' */