strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos)
{
size_t len;
- static char delim[3][8] = {
+ /* ',' 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"
return 0;
}
- /* skip leading ws and delimiters */
+ /* skip leading whitespace and delimiters */
*pos += strspn(*pos, delim[2]);
*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);