From e095cc064eb72ca0cee6d41622e39e7ea3f211a6 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 30 Jul 2010 01:00:26 +0200 Subject: [PATCH] Fix a problem when -k is specified and url's are specified in CSS code. --- NEWS | 3 +++ src/ChangeLog | 9 +++++++++ src/css-url.c | 2 +- src/html-url.c | 26 ++++++++++++++++++++------ src/html-url.h | 3 +-- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index d4a98037..28199f57 100644 --- a/NEWS +++ b/NEWS @@ -36,6 +36,9 @@ Please send GNU Wget bug reports to . ** By default, on server redirects, use the original URL to get the local file name. Close CVE-2010-2252. + +** Fix a problem when -k is used and some URLs are specified trough + CSS. * Changes in Wget 1.12 diff --git a/src/ChangeLog b/src/ChangeLog index 30f75cd6..aa074bf7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2010-07-30 Giuseppe Scrivano + + * html-url.h (struct map_context): Remove member `tail'. + + * html-url.c (append_url): Append the new url ordered by `position'. + (get_urls_html): Do not initialize `ctx.tail'. + + * css-url.c (get_urls_css_file): Do not initialize `ctx.tail'. + 2010-07-29 Giuseppe Scrivano * gnutls.c (wgnutls_peek): Don't read more data if the buffered peek diff --git a/src/css-url.c b/src/css-url.c index f3d8c909..ab8d6761 100644 --- a/src/css-url.c +++ b/src/css-url.c @@ -261,7 +261,7 @@ get_urls_css_file (const char *file, const char *url) DEBUGP (("Loaded %s (size %s).\n", file, number_to_static_string (fm->length))); ctx.text = fm->content; - ctx.head = ctx.tail = NULL; + ctx.head = NULL; ctx.base = NULL; ctx.parent_base = url ? url : opt.base_href; ctx.document_file = file; diff --git a/src/html-url.c b/src/html-url.c index 02092e5a..523f5e0d 100644 --- a/src/html-url.c +++ b/src/html-url.c @@ -335,13 +335,27 @@ append_url (const char *link_uri, int position, int size, else if (link_has_scheme) newel->link_complete_p = 1; - if (ctx->tail) + /* Append the new URL maintaining the order by position. */ + if (ctx->head == NULL) + ctx->head = newel; + else { - ctx->tail->next = newel; - ctx->tail = newel; + struct urlpos *it, *prev = NULL; + + it = ctx->head; + while (it && position > it->pos) + { + prev = it; + it = it->next; + } + + newel->next = it; + + if (prev) + prev->next = newel; + else + ctx->head = newel; } - else - ctx->tail = ctx->head = newel; return newel; } @@ -668,7 +682,7 @@ get_urls_html (const char *file, const char *url, bool *meta_disallow_follow, DEBUGP (("Loaded %s (size %s).\n", file, number_to_static_string (fm->length))); ctx.text = fm->content; - ctx.head = ctx.tail = NULL; + ctx.head = NULL; ctx.base = NULL; ctx.parent_base = url ? url : opt.base_href; ctx.document_file = file; diff --git a/src/html-url.h b/src/html-url.h index 458f2521..5592aad1 100644 --- a/src/html-url.h +++ b/src/html-url.h @@ -40,8 +40,7 @@ struct map_context { bool nofollow; /* whether NOFOLLOW was specified in a tag. */ - struct urlpos *head, *tail; /* List of URLs that is being - built. */ + struct urlpos *head; /* List of URLs that is being built. */ }; struct urlpos *get_urls_file (const char *); -- 2.39.2