aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2010-03-10 02:14:10 +0000
committercorvid <corvid@lavabit.com>2010-03-10 02:14:10 +0000
commit9e278e4897c10ffa7e115930a5594a02edf1f863 (patch)
treee7f0e1d9ec54e7fda4c8f541ef042f74305bf4d9
parent9d156d8dd2b060068876fd4472b46a3a7d28ea28 (diff)
separate out unquoting
-rw-r--r--dpi/cookies.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/dpi/cookies.c b/dpi/cookies.c
index eb8fbb11..b3182856 100644
--- a/dpi/cookies.c
+++ b/dpi/cookies.c
@@ -665,19 +665,27 @@ static void Cookies_eat_value(char **cookie_str)
*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) {