aboutsummaryrefslogtreecommitdiff
path: root/src/Cookies.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Cookies.c')
-rw-r--r--src/Cookies.c20
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);