From: hno <> Date: Fri, 20 Jun 2003 01:02:33 +0000 (+0000) Subject: 2003-05-21 01:51 hno X-Git-Tag: SQUID_3_0_PRE1~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7573ac0c3e4a40654652ceed865ba1d7634bddf;p=thirdparty%2Fsquid.git 2003-05-21 01:51 hno Bug #644: strListGetItem() failed to account for quoting, causing digest authentication to fail on URLs with comma and possibly other odd HTTP parsing errors. --- diff --git a/src/HttpHeaderTools.cc b/src/HttpHeaderTools.cc index d343d8761d..be7d77a650 100644 --- a/src/HttpHeaderTools.cc +++ b/src/HttpHeaderTools.cc @@ -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' */