summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2006-07-01 21:35:30 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2006-07-01 21:35:30 +0000
commit28a7ed4989b3798087258dbc7ac7109298316ef3 (patch)
tree1aa52808a89f0b015fce625f7691c34021c36e08
parent2dc65ac4149695daac5adf3ab24fff5625067d68 (diff)
downloadnetsurf-28a7ed4989b3798087258dbc7ac7109298316ef3.tar.gz
netsurf-28a7ed4989b3798087258dbc7ac7109298316ef3.tar.bz2
Relax domain matching to allow host a.com to match .a.com
svn path=/trunk/netsurf/; revision=2684
-rw-r--r--content/urldb.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/content/urldb.c b/content/urldb.c
index 0c4792857..35baecd2a 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -2554,6 +2554,7 @@ bool urldb_set_cookie(const char *header, const char *url)
/* Domain match fetch host with cookie domain */
if (strcasecmp(host, c->domain) != 0) {
int hlen, dlen;
+ char *domain = c->domain;
/* 4.3.2:iii */
if (host[0] >= '0' && host[0] <= '9') {
@@ -2565,13 +2566,20 @@ bool urldb_set_cookie(const char *header, const char *url)
hlen = strlen(host);
dlen = strlen(c->domain);
- if (hlen <= dlen) {
+ if (hlen <= dlen && hlen != dlen - 1) {
/* Partial match not possible */
urldb_free_cookie(c);
goto error;
}
- if (strcasecmp(host + (hlen - dlen), c->domain)) {
+ if (hlen == dlen - 1) {
+ /* Relax matching to allow
+ * host a.com to match .a.com */
+ domain++;
+ dlen--;
+ }
+
+ if (strcasecmp(host + (hlen - dlen), domain)) {
urldb_free_cookie(c);
goto error;
}
@@ -3313,6 +3321,8 @@ int main(void)
urldb_set_cookie("test=foo, bar, baz; path=/, quux=blah; path=/", "http://www.bbc.co.uk/");
+ urldb_set_cookie("a=b; path=/; domain=.a.com", "http://a.com/");
+
urldb_dump();
return 0;