Here is a patch for a potential feature change. I'm not sending it
to the wget-patches list yet, as I'm not sure if it should be
applied as is, or at all.

The feature change is a minor amendment to the (bogus) test for
whether an existing local copy of a file is text/html when the or
not when the --noclobber option is used, based on its suffix.

The current test assumes the local file is text/html if it has a
suffix of "html" or "htm". The amendment made by this patch
includes suffixes of the form "shtml", "phtml", etc. in the set
of suffixes assumed to indicate text/html files.

As it stands, the new test treats any "?html" suffix (where "?"
matches a single character as indicating a text/html file. Perhaps
this test should be tightened up to only allow a letter rather than
any character in this position.

I didn't bother testing for "?htm", as I've never seen it and can't
think why anyone would want to use it. (However, I do recall seeing
suffixes such as "sht" before now, i.e. "shtml" truncated to 3
characters, but perhaps that's going too far.)

Any comments?

Index: src/http.c
===================================================================
RCS file: /pack/anoncvs/wget/src/http.c,v
retrieving revision 1.85
diff -u -r1.85 http.c
--- src/http.c  2002/02/19 05:18:43     1.85
+++ src/http.c  2002/02/20 19:25:34
@@ -1462,8 +1462,10 @@
 
       /* #### Bogusness alert.  */
       /* If its suffix is "html" or "htm", assume text/html.  */
-      if (((suf = suffix (*hstat.local_file)) != NULL)
-         && (!strcmp (suf, "html") || !strcmp (suf, "htm")))
+      /* Also assume text/html if its suffix is "shtml", "phtml", etc. */
+      if (((suf = suffix (*hstat.local_file)) != NULL) && *suf
+         && (!strcmp (suf, "html") || !strcmp (suf, "htm")
+             || !strcmp(suf+1, "html")))
        *dt |= TEXTHTML;
 
       FREE_MAYBE (dummy);

Reply via email to