fielding 99/02/10 05:36:52
Modified: src/main util.c
src/test test_parser.c
Log:
Change ap_get_list_item to treat comments like a quoted string
rather than strip them. This corresponds to the expectation that
future HTTP fields will only use comments when they are useful.
Revision Changes Path
1.151 +24 -28 apache-1.3/src/main/util.c
Index: util.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/util.c,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -r1.150 -r1.151
--- util.c 1999/02/09 16:57:24 1.150
+++ util.c 1999/02/10 13:36:50 1.151
@@ -1039,10 +1039,10 @@
}
/* Retrieve an HTTP header field list item, as separated by a comma,
- * while stripping insignificant whitespace/comments and lowercasing anything
- * not in a quoted string. The return value is a new string containing
- * the converted list item (empty if it was all comments or NULL if none)
- * and the address of field is shifted to the next non-comma, non-whitespace.
+ * while stripping insignificant whitespace and lowercasing anything not in
+ * a quoted string or comment. The return value is a new string containing
+ * the converted list item (or NULL if none) and the address pointed to by
+ * field is shifted to the next non-comma, non-whitespace.
*/
API_EXPORT(char *) ap_get_list_item(pool *p, const char **field)
{
@@ -1061,9 +1061,9 @@
token = ap_palloc(p, tok_len + 1);
/* Scan the token again, but this time copy only the good bytes.
- * We skip extra whitespace and any whitespace around a '=' or ';',
- * strip comments, and lowercase normal characters not within a
- * quoted-string or quoted-pair. The result may be an empty string.
+ * We skip extra whitespace and any whitespace around a '=', '/',
+ * or ';' and lowercase normal characters not within a comment,
+ * quoted-string or quoted-pair.
*/
for (ptr = (const unsigned char *)tok_start, pos = (unsigned char
*)token;
*ptr && (in_qpair || in_qstr || in_com || *ptr != ',');
@@ -1071,57 +1071,53 @@
if (in_qpair) {
in_qpair = 0;
- if (!in_com)
- *pos++ = *ptr;
+ *pos++ = *ptr;
}
else {
switch (*ptr) {
case '\\': in_qpair = 1;
- if (in_com)
- break;
if (addspace == 1)
*pos++ = ' ';
*pos++ = *ptr;
addspace = 0;
break;
- case '"' : if (in_com)
- break;
- in_qstr = !in_qstr;
+ case '"' : if (!in_com)
+ in_qstr = !in_qstr;
if (addspace == 1)
*pos++ = ' ';
*pos++ = *ptr;
addspace = 0;
break;
- case '(' : if (in_qstr)
- *pos++ = *ptr;
- else
+ case '(' : if (!in_qstr)
++in_com;
+ if (addspace == 1)
+ *pos++ = ' ';
+ *pos++ = *ptr;
+ addspace = 0;
break;
case ')' : if (in_com)
--in_com;
- else
- *pos++ = *ptr;
+ *pos++ = *ptr;
+ addspace = 0;
break;
case ' ' :
- case '\t': if (in_com || addspace)
+ case '\t': if (addspace)
break;
- if (in_qstr)
+ if (in_com || in_qstr)
*pos++ = *ptr;
else
addspace = 1;
break;
case '=' :
- case ';' : if (in_com)
- break;
- if (!in_qstr)
+ case '/' :
+ case ';' : if (!(in_com || in_qstr))
addspace = -1;
*pos++ = *ptr;
break;
- default : if (in_com)
- break;
- if (addspace == 1)
+ default : if (addspace == 1)
*pos++ = ' ';
- *pos++ = in_qstr ? *ptr : ap_tolower(*ptr);
+ *pos++ = (in_com || in_qstr) ? *ptr
+ : ap_tolower(*ptr);
addspace = 0;
break;
}
1.2 +1 -2 apache-1.3/src/test/test_parser.c
Index: test_parser.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/test/test_parser.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- test_parser.c 1999/02/08 15:12:21 1.1
+++ test_parser.c 1999/02/10 13:36:51 1.2
@@ -6,8 +6,7 @@
gcc -g -O2 -I../os/unix -I../include -o test_parser \
-DSOLARIS2=250 -Wall -DALLOC_DEBUG -DPOOL_DEBUG \
../main/alloc.o ../main/buff.o ../main/util.o \
- ../main/http_log.o ../ap/libap.a \
- -lsocket -lnsl test_parser.c
+ ../ap/libap.a -lsocket -lnsl test_parser.c
*
* Roy Fielding, 1999
*/