From 0859ac620cfb0c4efd0ffc1b6bc0582ee570cde6 Mon Sep 17 00:00:00 2001 From: tradke Date: Tue, 13 Dec 2005 09:13:01 +0000 Subject: Another fix in HTTP_CookieGet() for the case when there is more than one cookie. git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@227 1faa4e14-9dd3-4be0-9f0e-ffe519881164 --- src/Cookies.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Cookies.c b/src/Cookies.c index 559c052..598115a 100644 --- a/src/Cookies.c +++ b/src/Cookies.c @@ -166,24 +166,22 @@ char *HTTP_CookieGet(httpRequest *request, const char *cookie_name) /* Get the cookie header */ if( HTTP_GetHeaderValueString( request, attribute, header ) ) { + size_t value_start = 0; String *name = String_Make( cookie_name ); - String *value = String_New(); - size_t index = 0; - - /* Search for "name=" */ ConcatCString (name, "="); - if (FindStringFrom (header, name, &index)) + + /* Search for "=" */ + if (FindStringFrom (header, name, &value_start)) { - /* cut "value" at the next ';' char or at EOS */ - size_t position = index + StringLength (name); - if (FindCharFrom (header, ';', &position)) + /* truncate "" at the next ';' char */ + size_t value_end = value_start + StringLength (name); + if (FindCharFrom (header, ';', &value_end)) { - TrimLeading (header, position); + StringTruncate (header, value_end); } - retval = Util_Strdup (GetBuffer (header) + index); + retval = Util_Strdup (GetBuffer (header) + value_start); } String_Delete(name); - String_Delete(value); } String_Delete(header); String_Delete(attribute); -- cgit v1.2.3