X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fhtml-url.c;h=f02982173cec0302e0295e68aaecac5abad5942d;hb=b1838bdfd197ec970d834ce5042995df92516841;hp=523f5e0dab1aa82f1431f7752be20742c356f4ec;hpb=e095cc064eb72ca0cee6d41622e39e7ea3f211a6;p=wget diff --git a/src/html-url.c b/src/html-url.c index 523f5e0d..f0298217 100644 --- a/src/html-url.c +++ b/src/html-url.c @@ -1,6 +1,6 @@ /* Collect URLs from HTML source. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This file is part of GNU Wget. @@ -36,6 +36,7 @@ as that of the covered work. */ #include #include +#include "exits.h" #include "html-parse.h" #include "url.h" #include "utils.h" @@ -164,6 +165,7 @@ static struct { to the attributes not mentioned here. We add them manually. */ static const char *additional_attributes[] = { "rel", /* used by tag_handle_link */ + "type", /* used by tag_handle_link */ "http-equiv", /* used by tag_handle_meta */ "name", /* used by tag_handle_meta */ "content", /* used by tag_handle_meta */ @@ -364,12 +366,27 @@ static void check_style_attr (struct taginfo *tag, struct map_context *ctx) { int attrind; + int raw_start; + int raw_len; char *style = find_attr (tag, "style", &attrind); if (!style) return; - /* raw pos and raw size include the quotes, hence the +1 -2 */ - get_urls_css (ctx, ATTR_POS(tag,attrind,ctx)+1, ATTR_SIZE(tag,attrind)-2); + /* raw pos and raw size include the quotes, skip them when they are + present. */ + raw_start = ATTR_POS (tag, attrind, ctx); + raw_len = ATTR_SIZE (tag, attrind); + if( *(char *)(ctx->text + raw_start) == '\'' + || *(char *)(ctx->text + raw_start) == '"') + { + raw_start += 1; + raw_len -= 2; + } + + if(raw_len <= 0) + return; + + get_urls_css (ctx, raw_start, raw_len); } /* All the tag_* functions are called from collect_tags_mapper, as @@ -490,8 +507,8 @@ tag_handle_link (int tagid, struct taginfo *tag, struct map_context *ctx) /* All link references are external, except those known not to be, such as style sheet and shortcut icon: - - + + */ if (href) { @@ -511,11 +528,18 @@ tag_handle_link (int tagid, struct taginfo *tag, struct map_context *ctx) { up->link_inline_p = 1; } + else + { + /* The external ones usually point to HTML pages, such as + + except when the type attribute says otherwise: + + */ + char *type = find_attr (tag, "type", NULL); + if (!type || strcasecmp (type, "text/html") == 0) + up->link_expect_html = 1; + } } - else - /* The external ones usually point to HTML pages, such as - */ - up->link_expect_html = 1; } } } @@ -651,8 +675,9 @@ collect_tags_mapper (struct taginfo *tag, void *arg) check_style_attr (tag, ctx); - if (tag->end_tag_p && (0 == strcasecmp (tag->name, "style")) && - tag->contents_begin && tag->contents_end) + if (tag->end_tag_p && (0 == strcasecmp (tag->name, "style")) + && tag->contents_begin && tag->contents_end + && tag->contents_begin <= tag->contents_end) { /* parse contents */ get_urls_css (ctx, tag->contents_begin - ctx->text, @@ -779,6 +804,13 @@ get_urls_file (const char *file) url_text = merged; } + char *new_url = rewrite_shorthand_url (url_text); + if (new_url) + { + xfree (url_text); + url_text = new_url; + } + url = url_parse (url_text, &up_error_code, NULL, false); if (!url) { @@ -787,6 +819,7 @@ get_urls_file (const char *file) file, url_text, error); xfree (url_text); xfree (error); + inform_exit_status (URLERROR); continue; } xfree (url_text);