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) - { - ctx->tail->next = newel; - ctx->tail = newel; - } + /* Append the new URL maintaining the order by position. */ + if (ctx->head == NULL) + ctx->head = newel; else - ctx->tail = ctx->head = 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; + } 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 *);