aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-04-14 18:21:17 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-04-14 18:21:17 +0000
commit2361aabbef12496c672bbc9a6e746e0510f21b0e (patch)
treeb99757b4e18d4916946d8b19c45e9d2b9874aac4
parente0cc8d2ce9b861d41b08d47f8574b710bcf95b53 (diff)
Dirk Manske made libcurl strip off white spaces from the beginning of cookie
contents.
-rw-r--r--lib/cookie.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/cookie.c b/lib/cookie.c
index fbf2ed0c4..51155786b 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -145,6 +145,8 @@ Curl_cookie_add(struct CookieInfo *c,
name, what)) {
/* this is a <name>=<what> pair */
+ char *whatptr;
+
/* Strip off trailing whitespace from the 'what' */
int len=strlen(what);
while(len && isspace((int)what[len-1])) {
@@ -152,15 +154,21 @@ Curl_cookie_add(struct CookieInfo *c,
len--;
}
+ /* Skip leading whitespace from the 'what' */
+ whatptr=what;
+ while(isspace((int)*whatptr)) {
+ whatptr++;
+ }
+
if(strequal("path", name)) {
- co->path=strdup(what);
+ co->path=strdup(whatptr);
}
else if(strequal("domain", name)) {
- co->domain=strdup(what);
- co->field1= (what[0]=='.')?2:1;
+ co->domain=strdup(whatptr);
+ co->field1= (whatptr[0]=='.')?2:1;
}
else if(strequal("version", name)) {
- co->version=strdup(what);
+ co->version=strdup(whatptr);
}
else if(strequal("max-age", name)) {
/* Defined in RFC2109:
@@ -172,17 +180,17 @@ Curl_cookie_add(struct CookieInfo *c,
cookie should be discarded immediately.
*/
- co->maxage = strdup(what);
+ co->maxage = strdup(whatptr);
co->expires =
atoi((*co->maxage=='\"')?&co->maxage[1]:&co->maxage[0]) + now;
}
else if(strequal("expires", name)) {
- co->expirestr=strdup(what);
+ co->expirestr=strdup(whatptr);
co->expires = curl_getdate(what, &now);
}
else if(!co->name) {
co->name = strdup(name);
- co->value = strdup(what);
+ co->value = strdup(whatptr);
}
/*
else this is the second (or more) name we don't know