File squid-3.0.PRE6-bug2541-bnc577347.patch of Package squid-beta
diff -ruN ../squid-3.0.PRE6.orig/src/HttpHeaderTools.cc ./src/HttpHeaderTools.cc
--- ../squid-3.0.PRE6.orig/src/HttpHeaderTools.cc 2007-05-07 20:12:28.000000000 +0200
+++ ./src/HttpHeaderTools.cc 2010-03-12 17:07:09.000000000 +0100
@@ -246,52 +246,51 @@
strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos)
{
size_t len;
- static char delim[2][3] = {
- { '"', '?', 0},
- { '"', '\\', 0}};
+ /* ',' is always enabled as field delimiter as this is required for
+ * processing merged header values properly, even if Cookie normally
+ * uses ';' as delimiter.
+ */
+ static char delim[3][8] = {
+ "\"?,",
+ "\"\\",
+ " ?,\t\r\n"
+ };
int quoted = 0;
assert(str && item && pos);
delim[0][1] = del;
+ delim[2][1] = del;
- if (*pos) {
- if (!**pos) /* end of string */
- return 0;
- else
- (*pos)++;
- } else {
+ if (!*pos) {
*pos = str->buf();
if (!*pos)
return 0;
}
- /* skip leading ws (ltrim) */
- *pos += xcountws(*pos);
+ /* skip leading ws and delimiters */
+ *pos += strspn(*pos, delim[2]);
- *item = *pos; /* remember item's start */
+ *item = *pos; /* remember item's start */
/* find next delimiter */
do {
*pos += strcspn(*pos, delim[quoted]);
- if (**pos == del)
- break;
-
if (**pos == '"') {
quoted = !quoted;
*pos += 1;
- }
-
- if (quoted && **pos == '\\') {
+ } else if (quoted && **pos == '\\') {
*pos += 1;
if (**pos)
*pos += 1;
+ } else {
+ break; /* Delimiter found, marking the end of this value */
}
} while (**pos);
- len = *pos - *item; /* *pos points to del or '\0' */
+ len = *pos - *item; /* *pos points to del or '\0' */
/* rtrim */
while (len > 0 && xisspace((*item)[len - 1]))