summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-01-30 01:44:57 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-01-30 01:44:57 +0000
commit9164f247c2e6e7cc61f1066c1096e4eb7641cde6 (patch)
treee8528a0cd88b89a74e6be6555a82b02c7964aaaf /content
parent1952b8b9ba8c7dcea577ef364e8e6e091072c6c1 (diff)
downloadnetsurf-9164f247c2e6e7cc61f1066c1096e4eb7641cde6.tar.gz
netsurf-9164f247c2e6e7cc61f1066c1096e4eb7641cde6.tar.bz2
Ensure plq is terminated when looking for an URL path.
Ensure fetchcache_redirect() normalizes the redirect destination. svn path=/trunk/netsurf/; revision=3807
Diffstat (limited to 'content')
-rw-r--r--content/fetchcache.c18
-rw-r--r--content/urldb.c3
2 files changed, 19 insertions, 2 deletions
diff --git a/content/fetchcache.c b/content/fetchcache.c
index c0e34e3aa..e11c6a765 100644
--- a/content/fetchcache.c
+++ b/content/fetchcache.c
@@ -768,7 +768,7 @@ void fetchcache_notmodified(struct content *c, const void *data)
void fetchcache_redirect(struct content *c, const void *data,
unsigned long size)
{
- char *url;
+ char *url, *url1;
char *referer;
long http_code = fetch_http_code(c->fetch);
const char *ref = fetch_get_referer(c->fetch);
@@ -843,16 +843,30 @@ void fetchcache_redirect(struct content *c, const void *data,
/* redirect URLs must be absolute by HTTP/1.1, but many
* sites send relative ones: treat them as relative to
* requested URL */
- result = url_join(data, c->url, &url);
+ result = url_join(data, c->url, &url1);
+ if (result != URL_FUNC_OK) {
+ msg_data.error = messages_get("BadRedirect");
+ content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ free(referer);
+ return;
+ }
+
+ /* Normalize redirect target -- this is vital as this URL may
+ * be inserted into the urldb, which expects normalized URLs */
+ result = url_normalize(url1, &url);
if (result != URL_FUNC_OK) {
msg_data.error = messages_get("BadRedirect");
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ free(url1);
free(referer);
return;
}
+ /* No longer need url1 */
+ free(url1);
+
/* Process users of this content */
while (c->user_list->next) {
intptr_t p1, p2;
diff --git a/content/urldb.c b/content/urldb.c
index cd4139423..4d5c59ae9 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -1827,6 +1827,9 @@ struct path_data *urldb_find_url(const char *url)
return NULL;
}
+ /* Ensure plq is terminated */
+ *plq = '\0';
+
copy = plq;
if (components.path) {
strcpy(copy, components.path);