summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2006-06-24 00:01:55 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2006-06-24 00:01:55 +0000
commitbb91584f7ce3f979a4b7b13b9bfaee2392f09f13 (patch)
treef4f4108126cb84e148ccadfd126a117a90800983 /content
parent73b13bff1227ce46588589fc8931274d83bfe1fd (diff)
downloadnetsurf-bb91584f7ce3f979a4b7b13b9bfaee2392f09f13.tar.gz
netsurf-bb91584f7ce3f979a4b7b13b9bfaee2392f09f13.tar.bz2
Strip day names from date strings before parsing; these are too variable
to bother with (and carry no information useful to us) Make expires avpair handling cater for dates after 2038. svn path=/trunk/netsurf/; revision=2642
Diffstat (limited to 'content')
-rw-r--r--content/urldb.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/content/urldb.c b/content/urldb.c
index 5d13b004f..ebcca6322 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -2764,8 +2764,27 @@ struct cookie *urldb_parse_cookie(const char *url, const char *cookie)
} else if (strcasecmp(n, "Version") == 0) {
c->version = atoi(v);
} else if (strcasecmp(n, "Expires") == 0) {
+ char *datenoday;
+
+ /* Strip dayname from date (these are hugely
+ * variable and liable to break the parser.
+ * They also serve no useful purpose) */
+ for (datenoday = v;
+ *datenoday && !isdigit(*datenoday);
+ datenoday++)
+ ; /* do nothing */
+
had_expires = true;
- expires = curl_getdate(v, NULL);
+ expires = curl_getdate(datenoday, NULL);
+ if (expires == -1) {
+ /* assume we have an unrepresentable
+ * date => force it to the maximum
+ * possible value of a 32bit time_t
+ * (this may break in 2038. We'll
+ * deal with that once we come to
+ * it) */
+ expires = (time_t)0x7fffffff;
+ }
} else if (!c->name) {
c->name = strdup(n);
c->value = strdup(v);
@@ -3255,6 +3274,8 @@ int main(void)
struct path_data *p;
int i;
+ url_init();
+
urldb_init();
for (i = 0; i != N_INPUTS; i++)
@@ -3296,6 +3317,10 @@ int main(void)
return 1;
}
+ urldb_set_cookie("mmblah=admin; path=/; expires=Thur, 31-Dec-2099 00:00:00 GMT\r\n", "http://www.minimarcos.org.uk/cgi-bin/forum/Blah.pl?,v=login,p=2");
+
+ urldb_set_cookie("BlahPW=B%7Eyx.22dJsrwk; path=/; expires=Thur, 31-Dec-2099 00:00:00 GMT\r\n", "http://www.minimarcos.org.uk/cgi-bin/forum/Blah.pl?,v=login,p=2");
+
urldb_dump();
return 0;