Author: joes
Date: Tue Feb 15 15:41:38 2005
New Revision: 153977

URL: http://svn.apache.org/viewcvs?view=rev&rev=153977
Log:

  apreq_parse_cookie_header() failed to parse RFC Cookie headers which
  contained no space chars after the '$Version=1' preamble.

Modified:
    httpd/apreq/branches/multi-env-unstable/CHANGES
    httpd/apreq/branches/multi-env-unstable/library/cookie.c
    httpd/apreq/branches/multi-env-unstable/library/t/at.c
    httpd/apreq/branches/multi-env-unstable/library/t/cookie.c

Modified: httpd/apreq/branches/multi-env-unstable/CHANGES
URL: 
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/CHANGES?view=diff&r1=153976&r2=153977
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/CHANGES (original)
+++ httpd/apreq/branches/multi-env-unstable/CHANGES Tue Feb 15 15:41:38 2005
@@ -6,6 +6,10 @@
 
 
 - C API [joes]
+  apreq_parse_cookie_header() failed to parse RFC Cookie headers which
+  contained no space chars after the '$Version=1' preamble.
+
+- C API [joes]
   Reorganize around include/, library/, and module/ dirs.
 
 - C Tests [joes]

Modified: httpd/apreq/branches/multi-env-unstable/library/cookie.c
URL: 
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/library/cookie.c?view=diff&r1=153976&r2=153977
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/library/cookie.c (original)
+++ httpd/apreq/branches/multi-env-unstable/library/cookie.c Tue Feb 15 
15:41:38 2005
@@ -270,12 +270,21 @@
     while (apr_isspace(*hdr))
         ++hdr;
 
-    /* XXX cheat: assume "$..." => "$Version" => RFC Cookie header */
 
-    if (*hdr == '$') { 
+    if (*hdr == '$') {
+        /* XXX cheat: assume "$..." => "$Version" => RFC Cookie header */
         version = RFC;
-        while (*hdr && !apr_isspace(*hdr))
-            ++hdr;
+    skip_version_string:
+        switch (*hdr++) {
+        case 0:
+            return APR_SUCCESS;
+        case ',':
+            goto parse_cookie_header;
+        case ';':
+            break;
+        default:
+            goto skip_version_string;
+        }
     }
 
     for (;;) {

Modified: httpd/apreq/branches/multi-env-unstable/library/t/at.c
URL: 
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/library/t/at.c?view=diff&r1=153976&r2=153977
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/library/t/at.c (original)
+++ httpd/apreq/branches/multi-env-unstable/library/t/at.c Tue Feb 15 15:41:38 
2005
@@ -121,7 +121,7 @@
     else if (is_ok && !AT_FLAG_TRACE(t->flags))
         format[14] = '\0';
     else if (is_fatal && ! is_ok)
-        comment = "bail";
+        comment = "fatal";
     else
         comment = is_todo ? "todo" : is_skip ? "skip" : "at";
 
@@ -144,16 +144,12 @@
         exit(-1);
 
     if (!is_ok && is_fatal) {
-        if (t->abort != NULL) {
-            at_trace(t, "Abandon %s, omitting tests %d - %d from this run.",
-                     t->name, t->prior + t->current + 1, t->prior + t->plan);
-            longjmp(*t->abort, 0);
-        }
-        else {
-            apr_pool_cleanup_kill(t->pool, t, test_cleanup);
-            at_report(t, "Bail out!");
-            exit(-1);
+        while (t->current++ < t->plan) {
+            snprintf(buf, 256, "not ok %d # skipped: aborting test %s",
+                     t->prior + t->current, t->name);
+            at_report(t, buf);
         }
+        longjmp(*t->abort, 0);
     }
 }
 

Modified: httpd/apreq/branches/multi-env-unstable/library/t/cookie.c
URL: 
http://svn.apache.org/viewcvs/httpd/apreq/branches/multi-env-unstable/library/t/cookie.c?view=diff&r1=153976&r2=153977
==============================================================================
--- httpd/apreq/branches/multi-env-unstable/library/t/cookie.c (original)
+++ httpd/apreq/branches/multi-env-unstable/library/t/cookie.c Tue Feb 15 
15:41:38 2005
@@ -23,7 +23,10 @@
                                 "flr=left-right; fll=left-left; "
                                 "good_one=1;bad";
 
-static apr_table_t *jar;
+static const char rfccookies[] = "$Version=1; first=a;$domain=quux;second=be,"
+                                 "$Version=1;third=cie";
+
+static apr_table_t *jar, *jar2;
 static apr_pool_t *p;
 
 static void jar_make(dAT)
@@ -31,10 +34,23 @@
     jar = apr_table_make(p, APREQ_DEFAULT_NELTS);
     AT_not_null(jar);
     AT_int_eq(apreq_parse_cookie_header(p, jar, nscookies), 
APREQ_ERROR_NOTOKEN);
+    jar2 = apr_table_make(p, APREQ_DEFAULT_NELTS);
+    AT_not_null(jar2);
+    AT_int_eq(apreq_parse_cookie_header(p, jar2, rfccookies), APR_SUCCESS);
 }
 
+static void jar_get_rfc(dAT)
+{
+    const char *val;
+    AT_not_null(val = apr_table_get(jar2, "first"));
+    AT_str_eq(val, "a");
+    AT_not_null(val = apr_table_get(jar2, "second"));
+    AT_str_eq(val, "be");
+    AT_not_null(val = apr_table_get(jar2, "third"));
+    AT_str_eq(val, "cie");
+}
 
-static void jar_get(dAT)
+static void jar_get_ns(dAT)
 {
 
     AT_str_eq(apr_table_get(jar, "a"), "1");
@@ -120,7 +136,7 @@
     AT_int_eq(apreq_ua_cookie_version(rfc), APREQ_COOKIE_VERSION_RFC);
 }
 
-#define dT(func, plan) {#func, func, plan}
+#define dT(func, plan) #func, func, plan
 
 
 int main(int argc, char *argv[])
@@ -128,11 +144,12 @@
     unsigned i, plan = 0;
     dAT;
     at_test_t test_list [] = {
-        dT(jar_make, 2),
-        dT(jar_get, 9),
-        dT(netscape_cookie, 7),
-        dT(rfc_cookie, 5),
-        dT(ua_version, 2)
+        { dT(jar_make, 4) },
+        { dT(jar_get_rfc, 6), "1 3 5" },
+        { dT(jar_get_ns, 9) },
+        { dT(netscape_cookie, 7) },
+        { dT(rfc_cookie, 5) },
+        { dT(ua_version, 2) }
     };
 
     apr_initialize();


Reply via email to