mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Process attributes in order in which they appear in the tag.
Submitted by Ian Abbott in <3B868388.6538.14A7848@localhost> based on analysis by Edward Sabol.
This commit is contained in:
parent
fa6aeb869d
commit
3d9dda6485
@ -1,3 +1,9 @@
|
||||
2001-08-24 Ian Abbott <abbotti@mev.co.uk>
|
||||
|
||||
* html-url.c (collect_tags_mapper): Fix bug converting links
|
||||
with -k option for tags with multiple link attributes by
|
||||
handling links in the order they appear.
|
||||
|
||||
2001-08-15 Ian Abbott <abbotti@mev.co.uk>
|
||||
|
||||
* ftp.c (ftp_loop_internal): Avoid a potential buffer overflow in
|
||||
|
@ -383,7 +383,7 @@ collect_tags_mapper (struct taginfo *tag, void *arg)
|
||||
{
|
||||
case TC_LINK:
|
||||
{
|
||||
int i;
|
||||
int i, id, first;
|
||||
int size = ARRAY_SIZE (url_tag_attr_map);
|
||||
for (i = 0; i < size; i++)
|
||||
if (url_tag_attr_map[i].tagid == tagid)
|
||||
@ -391,25 +391,34 @@ collect_tags_mapper (struct taginfo *tag, void *arg)
|
||||
/* We've found the index of url_tag_attr_map where the
|
||||
attributes of our tags begin. Now, look for every one of
|
||||
them, and handle it. */
|
||||
for (; (i < size && url_tag_attr_map[i].tagid == tagid); i++)
|
||||
/* Need to process the attributes in the order they appear in
|
||||
the tag, as this is required if we convert links. */
|
||||
first = i;
|
||||
for (id = 0; id < tag->nattrs; id++)
|
||||
{
|
||||
char *attr_value;
|
||||
int id;
|
||||
if (closure->dash_p_leaf_HTML
|
||||
&& (url_tag_attr_map[i].flags & AF_EXTERNAL))
|
||||
/* If we're at a -p leaf node, we don't want to retrieve
|
||||
links to references we know are external to this document,
|
||||
such as <a href=...>. */
|
||||
continue;
|
||||
/* This nested loop may seem inefficient (O(n^2)), but it's
|
||||
not, since the number of attributes (n) we loop over is
|
||||
extremely small. In the worst case of IMG with all its
|
||||
possible attributes, n^2 will be only 9. */
|
||||
for (i = first; (i < size && url_tag_attr_map[i].tagid == tagid);
|
||||
i++)
|
||||
{
|
||||
char *attr_value;
|
||||
if (closure->dash_p_leaf_HTML
|
||||
&& (url_tag_attr_map[i].flags & AF_EXTERNAL))
|
||||
/* If we're at a -p leaf node, we don't want to retrieve
|
||||
links to references we know are external to this document,
|
||||
such as <a href=...>. */
|
||||
continue;
|
||||
|
||||
/* This find_attr() buried in a loop may seem inefficient
|
||||
(O(n^2)), but it's not, since the number of attributes
|
||||
(n) we loop over is extremely small. In the worst case
|
||||
of IMG with all its possible attributes, n^2 will be
|
||||
only 9. */
|
||||
attr_value = find_attr (tag, url_tag_attr_map[i].attr_name, &id);
|
||||
if (attr_value)
|
||||
handle_link (closure, attr_value, tag, id);
|
||||
if (!strcasecmp (tag->attrs[id].name,
|
||||
url_tag_attr_map[i].attr_name))
|
||||
{
|
||||
attr_value = tag->attrs[id].value;
|
||||
if (attr_value)
|
||||
handle_link (closure, attr_value, tag, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user