changeset 1609:afbbdad5f64a

separate out unquoting
author corvid <corvid@lavabit.com>
date Wed, 10 Mar 2010 02:14:10 +0000
parents 5f8f8ce7a913
children 4b55c40d4eb9
files dpi/cookies.c
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/dpi/cookies.c	Wed Mar 10 02:01:49 2010 +0000
+++ b/dpi/cookies.c	Wed Mar 10 02:14:10 2010 +0000
@@ -665,19 +665,27 @@
       *cookie_str += strcspn(*cookie_str, ";");
 }
 
+static void Cookies_unquote_string(char *str)
+{
+   if (str && str[0] == '\"') {
+      uint_t len = strlen(str);
+
+      if (len > 1 && str[len - 1] == '\"') {
+         str[len - 1] = '\0';
+         while ((*str = str[1]))
+            str++;
+      }
+   }
+}
+
 /*
  * Handle Expires attribute.
- * Note that this CAN MODIFY the value string.
  */
 static time_t Cookies_expires_attr(char *value, const char *server_date)
 {
    time_t exptime;
 
-   if (*value == '"' && value[strlen(value) - 1] == '"') {
-      /* In this one case, pay attention to quotes */
-      value[strlen(value) - 1] = '\0';
-      value++;
-   }
+   Cookies_unquote_string(value);
    exptime = Cookies_create_timestamp(value);
    MSG("expires attr \"%s\" represented as %s", value, ctime(&exptime));
    if (exptime && server_date) {