]> granicus.if.org Git - apache/commitdiff
mod_mime_magic: Handle CRLF-format magic files so that it works with
authorJeff Trawick <trawick@apache.org>
Thu, 2 Jun 2005 18:24:27 +0000 (18:24 +0000)
committerJeff Trawick <trawick@apache.org>
Thu, 2 Jun 2005 18:24:27 +0000 (18:24 +0000)
the default installation on Windows.

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

CHANGES
modules/metadata/mod_mime_magic.c

diff --git a/CHANGES b/CHANGES
index b333020ba7156efb77e92e819a6204ae1d3d5683..327778da4cd0f064fb3826cb47fe05f42e474ec2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.5
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) mod_mime_magic: Handle CRLF-format magic files so that it works with
+     the default installation on Windows.  [Jeff Trawick]
+
   *) core: Allow multiple modules to register interest in a single 
      configuration command. [Paul Querna]
 
index 4cb096ea613691c1826d02b8ae50eebc7820c280..f4ca7207b2ad8a171a2bdd560077c7a9205d57b7 100644 (file)
@@ -947,12 +947,17 @@ static int apprentice(server_rec *s, apr_pool_t *p)
     /* parse it */
     for (lineno = 1; apr_file_gets(line, BUFSIZ, f) == APR_SUCCESS; lineno++) {
        int ws_offset;
+        char *last = line + strlen(line) - 1; /* guaranteed that len >= 1 */
 
-       /* delete newline */
-       if (line[0]) {
-           line[strlen(line) - 1] = '\0';
-       }
-
+       /* delete newline and potential carriage return */
+        if (*last == '\n') {
+            *last = '\0';
+            --last;
+        }
+        if (*last == '\r') {
+            *last = '\0';
+        }
+        
        /* skip leading whitespace */
        ws_offset = 0;
        while (line[ws_offset] && apr_isspace(line[ws_offset])) {