]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Ignore leading dots when looking for mime extensions
authorStefan Fritsch <sf@apache.org>
Fri, 21 Jan 2011 12:51:57 +0000 (12:51 +0000)
committerStefan Fritsch <sf@apache.org>
Fri, 21 Jan 2011 12:51:57 +0000 (12:51 +0000)
PR 50434

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1061791 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/http/mod_mime.c

diff --git a/CHANGES b/CHANGES
index 044b83df843eb8a4b09b7121c307a7dc11a29d13..b5695bb9f08b17d21f52cbc003fc0bae390391ab 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.3.11
 
+  *) mod_mime: Ignore leading dots when looking for mime extensions.
+     PR 50434 [Stefan Fritsch]
+
   *) core: Add support to set variables with the 'Define' directive. The
      variables that can then be used in the config using the ${VAR} syntax
      known from envvar interpolation. [Stefan Fritsch]
index 6277daa367a64c6fee3b25ce29df45a641c39f66..390707d38b352f2f067059011ce592cfb2f1b0ed 100644 (file)
@@ -755,7 +755,7 @@ static int find_ct(request_rec *r)
     mime_dir_config *conf;
     apr_array_header_t *exception_list;
     char *ext;
-    const char *fn, *type, *charset = NULL, *resource_name;
+    const char *fn, *fntmp, *type, *charset = NULL, *resource_name;
     int found_metadata = 0;
 
     if (r->finfo.filetype == APR_DIR) {
@@ -788,12 +788,27 @@ static int find_ct(request_rec *r)
         ++fn;
     }
 
+
     /* The exception list keeps track of those filename components that
      * are not associated with extensions indicating metadata.
      * The base name is always the first exception (i.e., "txt.html" has
      * a basename of "txt" even though it might look like an extension).
+     * Leading dots are considered to be part of the base name (a file named
+     * ".png" is likely not a png file but just a hidden file called png).
      */
-    ext = ap_getword(r->pool, &fn, '.');
+    fntmp = fn;
+    while (*fntmp == '.')
+        fntmp++;
+    fntmp = ap_strchr_c(fntmp, '.');
+    if (fntmp) {
+        ext = apr_pstrmemdup(r->pool, fn, fntmp - fn);
+        fn = fntmp + 1;
+    }
+    else {
+        ext = apr_pstrdup(r->pool, fn);
+        fn += strlen(fn);
+    }
+
     *((const char **)apr_array_push(exception_list)) = ext;
 
     /* Parse filename extensions which can be in any order