Skip to content

Commit 3ff8c35

Browse files
committed
[utils] cookie returns the value of the key
1 parent 2e91874 commit 3ff8c35

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/utils.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,21 @@ const char *cookie_get(http_message_t *request, const char *key)
412412
cookie = httpmessage_REQUEST(request, str_Cookie);
413413
if (cookie != NULL)
414414
{
415-
value = strstr(cookie, key);
415+
key = strstr(cookie, key);
416+
const char *end = cookie + strlen(cookie);
417+
const char *value = key;
418+
if (key != NULL)
419+
{
420+
while (value[0] != '\0' )
421+
{
422+
if (value[0] == ';')
423+
value = end;
424+
else if (value[0] == '=')
425+
break;
426+
else
427+
value++;
428+
}
429+
}
416430
}
417431
return value;
418432
}

0 commit comments

Comments
 (0)