gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r8025 - in libmicrohttpd: . src/daemon


From: gnunet
Subject: [GNUnet-SVN] r8025 - in libmicrohttpd: . src/daemon
Date: Sat, 27 Dec 2008 00:06:13 -0700 (MST)

Author: grothoff
Date: 2008-12-27 00:06:13 -0700 (Sat, 27 Dec 2008)
New Revision: 8025

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/daemon/connection.c
Log:
better cookie handling

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2008-12-27 06:17:53 UTC (rev 8024)
+++ libmicrohttpd/ChangeLog     2008-12-27 07:06:13 UTC (rev 8025)
@@ -1,5 +1,7 @@
 Fri Dec 26 23:08:04 MST 2008
         Fixed broken check for identical connection address. -CG
+        Making cookie parser more RFC2109 compliant (handle
+        spaces around key, allow value to be optional). -CG
 
 Sat Dec  6 18:36:17 MST 2008
         Added configure option to disable checking for CURL support.

Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c       2008-12-27 06:17:53 UTC (rev 
8024)
+++ libmicrohttpd/src/daemon/connection.c       2008-12-27 07:06:13 UTC (rev 
8025)
@@ -951,8 +951,11 @@
   const char *hdr;
   char *cpy;
   char *pos;
+  char *sce;
   char *semicolon;
   char *equals;
+  char *ekill;
+  char old;
   int quotes;
 
   hdr = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "Cookie");
@@ -972,11 +975,37 @@
   pos = cpy;
   while (pos != NULL)
     {
-      equals = strstr (pos, "=");
-      if (equals == NULL)
-        break;
-      equals[0] = '\0';
-      equals++;
+      while (*pos == ' ')
+       pos++; /* skip spaces */
+      
+      sce = pos;
+      while ( ( (*sce) != '\0') &&
+             ( (*sce) != ',') &&
+             ( (*sce) != ';') &&
+             ( (*sce) != '=') )
+       sce++;
+      /* remove tailing whitespace (if any) from key */
+      ekill = sce - 1;
+      while ( (*ekill == ' ') &&
+             (ekill >= pos) )
+       *(ekill--) = '\0';
+      old = *sce;
+      *sce = '\0';
+      if (old != '=')
+       {
+         /* value part omitted, use empty string... */
+         if (MHD_NO ==
+             connection_add_header (connection,
+                                    pos,
+                                    "",
+                                    MHD_COOKIE_KIND))
+           return MHD_NO;
+         if (old == '\0')
+           break;
+         pos = sce + 1;
+         continue;
+       }       
+      equals = sce + 1;
       quotes = 0;
       semicolon = equals;
       while ((semicolon[0] != '\0') &&





reply via email to

[Prev in Thread] Current Thread [Next in Thread]