]> sjero.net Git - wget/blobdiff - src/html-url.c
Get rid of the supplementary bool pointer in url_parse () arguments; UGLY :)
[wget] / src / html-url.c
index e9f2773ab409eeabb49966fcc9f7a8e6fede8a39..5a0682d3f80eaab886cdc997fa08ab3c5d26ef54 100644 (file)
@@ -42,6 +42,7 @@ as that of the covered work.  */
 #include "hash.h"
 #include "convert.h"
 #include "recur.h"              /* declaration of get_urls_html */
+#include "iri.h"
 
 struct map_context;
 
@@ -185,7 +186,7 @@ init_interesting (void)
      matches the user's preferences as specified through --ignore-tags
      and --follow-tags.  */
 
-  int i;
+  size_t i;
   interesting_tags = make_nocase_string_hash_table (countof (known_tags));
 
   /* First, add all the tags we know hot to handle, mapped to their
@@ -291,7 +292,9 @@ append_url (const char *link_uri,
           return NULL;
         }
 
+      set_ugly_no_encode (true);
       url = url_parse (link_uri, NULL);
+      set_ugly_no_encode (false);
       if (!url)
         {
           DEBUGP (("%s: link \"%s\" doesn't parse.\n",
@@ -310,7 +313,9 @@ append_url (const char *link_uri,
       DEBUGP (("%s: merge(\"%s\", \"%s\") -> %s\n",
                ctx->document_file, base, link_uri, complete_uri));
 
+      set_ugly_no_encode (true);
       url = url_parse (complete_uri, NULL);
+      set_ugly_no_encode (false);
       if (!url)
         {
           DEBUGP (("%s: merged link \"%s\" doesn't parse.\n",
@@ -355,7 +360,8 @@ append_url (const char *link_uri,
 static void
 tag_find_urls (int tagid, struct taginfo *tag, struct map_context *ctx)
 {
-  int i, attrind;
+  size_t i;
+  int attrind;
   int first = -1;
 
   for (i = 0; i < countof (tag_url_attributes); i++)
@@ -382,7 +388,7 @@ tag_find_urls (int tagid, struct taginfo *tag, struct map_context *ctx)
       /* Find whether TAG/ATTRIND is a combination that contains a
          URL. */
       char *link = tag->attrs[attrind].value;
-      const int size = countof (tag_url_attributes);
+      const size_t size = countof (tag_url_attributes);
 
       /* If you're cringing at the inefficiency of the nested loops,
          remember that they both iterate over a very small number of
@@ -533,6 +539,25 @@ tag_handle_meta (int tagid, struct taginfo *tag, struct map_context *ctx)
           entry->link_expect_html = 1;
         }
     }
+  else if (http_equiv && 0 == strcasecmp (http_equiv, "content-type"))
+    {
+      /* Handle stuff like:
+         <meta http-equiv="Content-Type" content="text/html; charset=CHARSET"> */
+
+      char *mcharset;
+      char *content = find_attr (tag, "content", NULL);
+      if (!content)
+        return;
+
+      mcharset = parse_charset (content);
+      if (!mcharset)
+        return;
+
+      /*logprintf (LOG_VERBOSE, "Meta tag charset : %s\n", quote (mcharset));*/
+
+      set_current_charset (mcharset);
+      xfree (mcharset);
+    }
   else if (name && 0 == strcasecmp (name, "robots"))
     {
       /* Handle stuff like:
@@ -690,7 +715,9 @@ get_urls_file (const char *file)
           url_text = merged;
         }
 
+      set_ugly_no_encode (true);
       url = url_parse (url_text, &up_error_code);
+      set_ugly_no_encode (false);
       if (!url)
         {
           logprintf (LOG_NOTQUIET, _("%s: Invalid URL %s: %s\n"),