~ubuntu-branches/ubuntu/precise/wget/precise-proposed

« back to all changes in this revision

Viewing changes to src/html-url.c

  • Committer: Bazaar Package Importer
  • Author(s): Noèl Köthe
  • Date: 2005-06-26 16:46:25 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050626164625-jjcde8hyztx7xq7o
Tags: 1.10-2
* wget-fix_error--save-headers patch from upstream
  (closes: Bug#314728)
* don't pattern-match server redirects patch from upstream
  (closes: Bug#163243)
* correct de.po typos
  (closes: Bug#313883)
* wget-E_html_behind_file_counting fix problem with adding the
  numbers after the html extension
* updated Standards-Version: to 3.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include "utils.h"
46
46
#include "hash.h"
47
47
#include "convert.h"
 
48
#include "recur.h"              /* declaration of get_urls_html */
48
49
 
49
50
#ifndef errno
50
51
extern int errno;
81
82
  TAG_LAYER,
82
83
  TAG_LINK,
83
84
  TAG_META,
 
85
  TAG_OBJECT,
84
86
  TAG_OVERLAY,
85
87
  TAG_SCRIPT,
86
88
  TAG_TABLE,
111
113
  { TAG_LAYER,   "layer",       tag_find_urls },
112
114
  { TAG_LINK,    "link",        tag_handle_link },
113
115
  { TAG_META,    "meta",        tag_handle_meta },
 
116
  { TAG_OBJECT,  "object",      tag_find_urls },
114
117
  { TAG_OVERLAY, "overlay",     tag_find_urls },
115
118
  { TAG_SCRIPT,  "script",      tag_find_urls },
116
119
  { TAG_TABLE,   "table",       tag_find_urls },
157
160
  { TAG_IMG,            "src",          ATTR_INLINE },
158
161
  { TAG_INPUT,          "src",          ATTR_INLINE },
159
162
  { TAG_LAYER,          "src",          ATTR_INLINE | ATTR_HTML },
 
163
  { TAG_OBJECT,         "data",         ATTR_INLINE },
160
164
  { TAG_OVERLAY,        "src",          ATTR_INLINE | ATTR_HTML },
161
165
  { TAG_SCRIPT,         "src",          ATTR_INLINE },
162
166
  { TAG_TABLE,          "background",   ATTR_INLINE },
227
231
  /* Add the attributes we care about. */
228
232
  interesting_attributes = make_nocase_string_hash_table (10);
229
233
  for (i = 0; i < countof (additional_attributes); i++)
230
 
    string_set_add (interesting_attributes, additional_attributes[i]);
 
234
    hash_table_put (interesting_attributes, additional_attributes[i], "1");
231
235
  for (i = 0; i < countof (tag_url_attributes); i++)
232
 
    string_set_add (interesting_attributes, tag_url_attributes[i].attr_name);
 
236
    hash_table_put (interesting_attributes,
 
237
                    tag_url_attributes[i].attr_name, "1");
233
238
}
234
239
 
235
240
/* Find the value of attribute named NAME in the taginfo TAG.  If the
327
332
 
328
333
  DEBUGP (("appending \"%s\" to urlpos.\n", url->url));
329
334
 
330
 
  newel = (struct urlpos *)xmalloc (sizeof (struct urlpos));
331
 
  memset (newel, 0, sizeof (*newel));
332
 
 
333
 
  newel->next = NULL;
 
335
  newel = xnew0 (struct urlpos);
334
336
  newel->url = url;
335
337
  newel->pos = tag->attrs[attrind].value_raw_beginning - ctx->text;
336
338
  newel->size = tag->attrs[attrind].value_raw_size;
479
481
              && (0 == strcasecmp (rel, "stylesheet")
480
482
                  || 0 == strcasecmp (rel, "shortcut icon")))
481
483
            up->link_inline_p = 1;
 
484
          else
 
485
            /* The external ones usually point to HTML pages, such as
 
486
               <link rel="next" href="..."> */
 
487
            up->link_expect_html = 1;
482
488
        }
483
489
    }
484
490
}
598
604
      logprintf (LOG_NOTQUIET, "%s: %s\n", file, strerror (errno));
599
605
      return NULL;
600
606
    }
601
 
  DEBUGP (("Loaded %s (size %ld).\n", file, fm->length));
 
607
  DEBUGP (("Loaded %s (size %s).\n", file, number_to_static_string (fm->length)));
602
608
 
603
609
  ctx.text = fm->content;
604
610
  ctx.head = ctx.tail = NULL;
611
617
    init_interesting ();
612
618
 
613
619
  /* Specify MHT_TRIM_VALUES because of buggy HTML generators that
614
 
     generate <a href=" foo"> instead of <a href="foo"> (Netscape
615
 
     ignores spaces as well.)  If you really mean space, use &32; or
616
 
     %20.  */
 
620
     generate <a href=" foo"> instead of <a href="foo"> (browsers
 
621
     ignore spaces as well.)  If you really mean space, use &32; or
 
622
     %20.  MHT_TRIM_VALUES also causes squashing of embedded newlines,
 
623
     e.g. in <img src="foo.[newline]html">.  Such newlines are also
 
624
     ignored by IE and Mozilla and are presumably introduced by
 
625
     writing HTML with editors that force word wrap.  */
617
626
  flags = MHT_TRIM_VALUES;
618
627
  if (opt.strict_comments)
619
628
    flags |= MHT_STRICT_COMMENTS;
625
634
  if (meta_disallow_follow)
626
635
    *meta_disallow_follow = ctx.nofollow;
627
636
 
628
 
  FREE_MAYBE (ctx.base);
 
637
  xfree_null (ctx.base);
629
638
  read_file_free (fm);
630
639
  return ctx.head;
631
640
}
647
656
      logprintf (LOG_NOTQUIET, "%s: %s\n", file, strerror (errno));
648
657
      return NULL;
649
658
    }
650
 
  DEBUGP (("Loaded %s (size %ld).\n", file, fm->length));
 
659
  DEBUGP (("Loaded %s (size %s).\n", file, number_to_static_string (fm->length)));
651
660
 
652
661
  head = tail = NULL;
653
662
  text = fm->content;
700
709
        }
701
710
      xfree (url_text);
702
711
 
703
 
      entry = (struct urlpos *)xmalloc (sizeof (struct urlpos));
704
 
      memset (entry, 0, sizeof (*entry));
 
712
      entry = xnew0 (struct urlpos);
705
713
      entry->next = NULL;
706
714
      entry->url = url;
707
715
 
718
726
void
719
727
cleanup_html_url (void)
720
728
{
721
 
  FREE_MAYBE (interesting_tags);
722
 
  FREE_MAYBE (interesting_attributes);
 
729
  /* Destroy the hash tables.  The hash table keys and values are not
 
730
     allocated by this code, so we don't need to free them here.  */
 
731
  if (interesting_tags)
 
732
    hash_table_destroy (interesting_tags);
 
733
  if (interesting_attributes)
 
734
    hash_table_destroy (interesting_attributes);
723
735
}