aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-21 20:40:15 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-21 20:40:15 +0000
commit755f98e7687a1fc2a7ff363212803b39897897a0 (patch)
treeea9937317e931a527f550f4aa2645f4b2209c87a
parentaadc797225906ba02fab4e1ad29b484acd4751b3 (diff)
While talking to host a.b.c, libcurl did wrongly not accept cookies that were
set to the domain .a.b.c (that is with a dot prefix). This is now fixed and test case 171 verifies it.
-rw-r--r--CHANGES5
-rw-r--r--lib/cookie.c3
-rw-r--r--tests/data/Makefile.am2
-rw-r--r--tests/data/test17147
4 files changed, 56 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index d3dd5922c..3dfb5cde0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,11 @@
Changelog
+Daniel (21 May 2004)
+- While talking to host a.b.c, libcurl did wrongly not accept cookies that
+ were set to the domain .a.b.c (that is with a dot prefix). This is now fixed
+ and test case 171 verifies it.
+
Daniel (20 May 2004)
- Jesse Noller reported that the upload speed info reported by libcurl was
wrong. The same was true for the download speed. Fixed now.
diff --git a/lib/cookie.c b/lib/cookie.c
index 693b5f98e..d31bcd114 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -261,6 +261,9 @@ Curl_cookie_add(struct SessionHandle *data,
/* Now, we make sure that our host is within the given domain,
or the given domain is not valid and thus cannot be set. */
+ if('.' == whatptr[0])
+ whatptr++; /* ignore preceeding dot */
+
if(!domain || tailmatch(whatptr, domain)) {
const char *tailptr=whatptr;
if(tailptr[0] == '.')
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 412fcda7b..a6446d7d6 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -23,7 +23,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
test203 test93 test94 test95 test509 test510 test97 test98 test99 \
test150 test151 test152 test153 test154 test155 test156 test157 \
test158 test159 test511 test160 test161 test162 test163 test164 \
- test512 test165 test166 test167 test168 test169 test170
+ test512 test165 test166 test167 test168 test169 test170 test171
# The following tests have been removed from the dist since they no longer
# work. We need to fix the test suite's FTPS server first, then bring them
diff --git a/tests/data/test171 b/tests/data/test171
new file mode 100644
index 000000000..9a3519828
--- /dev/null
+++ b/tests/data/test171
@@ -0,0 +1,47 @@
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Tue, 25 Sep 2001 19:37:44 GMT
+Content-Type: text/html
+Set-Cookie: XToken=xt;Domain=.z.x.com;Path=/
+Cache-control: private
+Content-Length: 62
+
+This server reply is for testing a simple Location: following
+</data>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+HTTP, get cookies and store in cookie jar
+ </name>
+ <command>
+-c log/jar171 -x %HOSTIP:%HOSTPORT http://z.x.com/171
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET http://z.x.com/171 HTTP/1.1
+Host: z.x.com
+Pragma: no-cache
+Accept: */*
+
+</protocol>
+<file name="log/jar171">
+# Netscape HTTP Cookie File
+# http://www.netscape.com/newsref/std/cookie_spec.html
+# This file was generated by libcurl! Edit at your own risk.
+
+.z.x.com TRUE / FALSE 0 XToken xt
+</file>
+</verify>