]> sjero.net Git - wget/commitdiff
Fix a problem when -k is specified and url's are specified in CSS code.
authorGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 29 Jul 2010 23:00:26 +0000 (01:00 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 29 Jul 2010 23:00:26 +0000 (01:00 +0200)
NEWS
src/ChangeLog
src/css-url.c
src/html-url.c
src/html-url.h

diff --git a/NEWS b/NEWS
index d4a98037f9d4f64b316e72d58f0a54e07846da28..28199f57462e40c3363ea72c94c97d6eee2b9ade 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,9 @@ Please send GNU Wget bug reports to <bug-wget@gnu.org>.
 
 ** 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.
 \f
 * Changes in Wget 1.12
 
index 30f75cd6d0c028fbc76adbf36ae79c4e791d272a..aa074bf7766ccd606038f76ef144d70c4b6cb120 100644 (file)
@@ -1,3 +1,12 @@
+2010-07-30  Giuseppe Scrivano  <gscrivano@gnu.org>
+
+       * 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  <gscrivano@gnu.org>
 
        * gnutls.c (wgnutls_peek): Don't read more data if the buffered peek
index f3d8c909eb417a1b58d9545485bf1af19fdadadd..ab8d67612ca4e54ed6f90ac5e0cd427dedd275e4 100644 (file)
@@ -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;
index 02092e5a31023a1322d8b05f787d0028ff4bc964..523f5e0dab1aa82f1431f7752be20742c356f4ec 100644 (file)
@@ -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;
index 458f2521ea6af4680e28ad8a692335abb5ca8732..5592aad1c61b2bb82d469a3895433c28c5db9270 100644 (file)
@@ -40,8 +40,7 @@ struct map_context {
   bool nofollow;               /* whether NOFOLLOW was specified in a
                                    <meta name=robots> 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 *);