From 9e278e4897c10ffa7e115930a5594a02edf1f863 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 10 Mar 2010 02:14:10 +0000 Subject: separate out unquoting --- dpi/cookies.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'dpi/cookies.c') 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) { -- cgit v1.2.3