]> sjero.net Git - wget/blobdiff - src/http.c
Automated merge.
[wget] / src / http.c
index 58e9b14a94453ff5477b745a779be2d1411595d3..543165fdd0a7b75f05859b7ad021ccec8b539144 100644 (file)
@@ -2040,9 +2040,32 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
       char *tmp = strchr (type, ';');
       if (tmp)
         {
+#ifdef ENABLE_IRI
+          char *tmp2 = tmp + 1;
+#endif
+
           while (tmp > type && c_isspace (tmp[-1]))
             --tmp;
           *tmp = '\0';
+
+#ifdef ENABLE_IRI
+          if (opt.enable_iri && *tmp2 != '\0' &&
+              (tmp = strstr (tmp2, "charset=")) != NULL)
+            {
+              tmp += 8;
+              tmp2 = tmp;
+
+              while (*tmp2 && !c_isspace (*tmp2))
+                tmp2++;
+
+              if (tmp2 > tmp)
+                {
+                  *tmp2 = '\0';
+                  /* sXXXav : check given charset */
+                  logprintf (LOG_VERBOSE, "HTTP charset: `%s'\n", tmp);
+                }
+            }
+#endif
         }
     }
   hs->newloc = resp_header_strdup (resp, "Location");
@@ -3020,10 +3043,11 @@ digest_authentication_encode (const char *au, const char *user,
   while (extract_param (&au, &name, &value, ','))
     {
       size_t i;
+      size_t namelen = name.e - name.b;
       for (i = 0; i < countof (options); i++)
-        if ((size_t) (name.e - name.b) == strlen (options[i].name)
+        if (namelen == strlen (options[i].name)
             && 0 == strncmp (name.b, options[i].name,
-                             (size_t) (name.e - name.b)))
+                             namelen))
           {
             *options[i].variable = strdupdelim (value.b, value.e);
             break;
@@ -3103,9 +3127,10 @@ username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\"",
    first argument and are followed by whitespace or terminating \0.
    The comparison is case-insensitive.  */
 #define STARTS(literal, b, e)                           \
-  (((size_t) ((e) - (b))) >= STRSIZE (literal) \
+  ((e > b) \
+   && ((size_t) ((e) - (b))) >= STRSIZE (literal)   \
    && 0 == strncasecmp (b, literal, STRSIZE (literal))  \
-   && ((e) - (b) == STRSIZE (literal)                   \
+   && ((size_t) ((e) - (b)) == STRSIZE (literal)          \
        || c_isspace (b[STRSIZE (literal)])))
 
 static bool