mirror of
https://github.com/mirror/wget.git
synced 2025-03-26 11:16:29 +08: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>
|
2001-08-15 Ian Abbott <abbotti@mev.co.uk>
|
||||||
|
|
||||||
* ftp.c (ftp_loop_internal): Avoid a potential buffer overflow in
|
* 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:
|
case TC_LINK:
|
||||||
{
|
{
|
||||||
int i;
|
int i, id, first;
|
||||||
int size = ARRAY_SIZE (url_tag_attr_map);
|
int size = ARRAY_SIZE (url_tag_attr_map);
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
if (url_tag_attr_map[i].tagid == tagid)
|
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
|
/* We've found the index of url_tag_attr_map where the
|
||||||
attributes of our tags begin. Now, look for every one of
|
attributes of our tags begin. Now, look for every one of
|
||||||
them, and handle it. */
|
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;
|
/* This nested loop may seem inefficient (O(n^2)), but it's
|
||||||
int id;
|
not, since the number of attributes (n) we loop over is
|
||||||
if (closure->dash_p_leaf_HTML
|
extremely small. In the worst case of IMG with all its
|
||||||
&& (url_tag_attr_map[i].flags & AF_EXTERNAL))
|
possible attributes, n^2 will be only 9. */
|
||||||
/* If we're at a -p leaf node, we don't want to retrieve
|
for (i = first; (i < size && url_tag_attr_map[i].tagid == tagid);
|
||||||
links to references we know are external to this document,
|
i++)
|
||||||
such as <a href=...>. */
|
{
|
||||||
continue;
|
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
|
if (!strcasecmp (tag->attrs[id].name,
|
||||||
(O(n^2)), but it's not, since the number of attributes
|
url_tag_attr_map[i].attr_name))
|
||||||
(n) we loop over is extremely small. In the worst case
|
{
|
||||||
of IMG with all its possible attributes, n^2 will be
|
attr_value = tag->attrs[id].value;
|
||||||
only 9. */
|
if (attr_value)
|
||||||
attr_value = find_attr (tag, url_tag_attr_map[i].attr_name, &id);
|
handle_link (closure, attr_value, tag, id);
|
||||||
if (attr_value)
|
}
|
||||||
handle_link (closure, attr_value, tag, id);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user