]> granicus.if.org Git - apache/commitdiff
If mod_mime_magic does not know the content-type, do not attempt to guess.
authorJustin Erenkrantz <jerenkrantz@apache.org>
Wed, 19 Feb 2003 05:58:00 +0000 (05:58 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Wed, 19 Feb 2003 05:58:00 +0000 (05:58 +0000)
PR: 16908
Submitted by: Andrew Gapon <agapon@telcordia.com>
Reviewed by: Justin Erenkrantz

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

CHANGES
modules/metadata/mod_mime_magic.c

diff --git a/CHANGES b/CHANGES
index a8b291b80eeca24c83e10dbfdd30bf669ebfeabc..4bfeb323b3343e1ff53781953be7769529db9e75 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) If mod_mime_magic does not know the content-type, do not attempt to
+     guess.  PR 16908.  [Andrew Gapon <agapon@telcordia.com>]
+
   *) Fix apxs to insert LoadModule directives only outside of sections.
      PR 9012.  [AndrĂ© Malo]
 
index 85f60fdedc2b5f59f5594993d5893c08fc8f8c58..90b9816922bba322f8f51c75100598ed08fd6e3f 100644 (file)
@@ -257,7 +257,7 @@ union record {
 static int ascmagic(request_rec *, unsigned char *, apr_size_t);
 static int is_tar(unsigned char *, apr_size_t);
 static int softmagic(request_rec *, unsigned char *, apr_size_t);
-static void tryit(request_rec *, unsigned char *, apr_size_t, int);
+static int tryit(request_rec *, unsigned char *, apr_size_t, int);
 static int zmagic(request_rec *, unsigned char *, apr_size_t);
 
 static int getvalue(server_rec *, struct magic *, char **);
@@ -903,11 +903,15 @@ static int magic_process(request_rec *r)
        return HTTP_INTERNAL_SERVER_ERROR;
     }
 
-    if (nbytes == 0)
-       magic_rsl_puts(r, MIME_TEXT_UNKNOWN);
+    if (nbytes == 0) {
+        return DECLINED;
+    }
     else {
        buf[nbytes++] = '\0';   /* null-terminate it */
-       tryit(r, buf, nbytes, 1); 
+        result = tryit(r, buf, nbytes, 1);
+       if (result != OK) {
+            return result;
+        }
     }
 
     (void) apr_file_close(fd);
@@ -917,32 +921,33 @@ static int magic_process(request_rec *r)
 }
 
 
-static void tryit(request_rec *r, unsigned char *buf, apr_size_t nb, int checkzmagic)
+static int tryit(request_rec *r, unsigned char *buf, apr_size_t nb,
+                 int checkzmagic)
 {
     /*
      * Try compression stuff
      */
        if (checkzmagic == 1) {  
                        if (zmagic(r, buf, nb) == 1)
-                       return;
+                       return OK;
        }
 
     /*
      * try tests in /etc/magic (or surrogate magic file)
      */
     if (softmagic(r, buf, nb) == 1)
-       return;
+       return OK;
 
     /*
      * try known keywords, check for ascii-ness too.
      */
     if (ascmagic(r, buf, nb) == 1)
-       return;
+       return OK;
 
     /*
      * abandon hope, all ye who remain here
      */
-    magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
+    return DECLINED;
 }
 
 #define    EATAB {while (apr_isspace(*l))  ++l;}
@@ -2070,16 +2075,7 @@ static int ascmagic(request_rec *r, unsigned char *buf, apr_size_t nbytes)
     }
 
     /* all else fails, but it is ascii... */
-    if (has_escapes) {
-       /* text with escape sequences */
-       /* we leave this open for further differentiation later */
-       magic_rsl_puts(r, "text/plain");
-    }
-    else {
-       /* plain text */
-       magic_rsl_puts(r, "text/plain");
-    }
-    return 1;
+    return 0;
 }
 
 
@@ -2141,7 +2137,9 @@ static int zmagic(request_rec *r, unsigned char *buf, apr_size_t nbytes)
        return 0;
 
     if ((newsize = uncompress(r, i, &newbuf, nbytes)) > 0) {
-       tryit(r, newbuf, newsize, 0);
+       if (tryit(r, newbuf, newsize, 0) != OK) {
+            return 0;
+        }
 
        /* set encoding type in the request record */
        r->content_encoding = compr[i].encoding;