You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2011/01/21 13:51:57 UTC

svn commit: r1061791 - in /httpd/httpd/trunk: CHANGES modules/http/mod_mime.c

Author: sf
Date: Fri Jan 21 12:51:57 2011
New Revision: 1061791

URL: http://svn.apache.org/viewvc?rev=1061791&view=rev
Log:
Ignore leading dots when looking for mime extensions
PR 50434

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/http/mod_mime.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1061791&r1=1061790&r2=1061791&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Fri Jan 21 12:51:57 2011
@@ -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]

Modified: httpd/httpd/trunk/modules/http/mod_mime.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/mod_mime.c?rev=1061791&r1=1061790&r2=1061791&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/http/mod_mime.c (original)
+++ httpd/httpd/trunk/modules/http/mod_mime.c Fri Jan 21 12:51:57 2011
@@ -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