diff options
author | tradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164> | 2005-12-13 09:13:01 +0000 |
---|---|---|
committer | tradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164> | 2005-12-13 09:13:01 +0000 |
commit | 0859ac620cfb0c4efd0ffc1b6bc0582ee570cde6 (patch) | |
tree | a95e74475ed06e56a489c3448ec0355e8cc31e3e | |
parent | 258b12d17fdc1c2b4359b0626a0498c357e03b9e (diff) |
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
-rw-r--r-- | src/Cookies.c | 20 |
1 files 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 "<name>=" */ + 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 "<value>" 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); |