summaryrefslogtreecommitdiffstats
path: root/modules/metadata
diff options
context:
space:
mode:
authorJustin Erenkrantz <jerenkrantz@apache.org>2003-02-19 06:58:00 +0100
committerJustin Erenkrantz <jerenkrantz@apache.org>2003-02-19 06:58:00 +0100
commitd608ebd0f920c5bb4cc77c0ebd1356259e94f2ff (patch)
treed20a83b8e333282a4c291cfd1b8b726c017acd01 /modules/metadata
parentinsert LoadModule directives only outside of sections. (diff)
downloadapache2-d608ebd0f920c5bb4cc77c0ebd1356259e94f2ff.tar.xz
apache2-d608ebd0f920c5bb4cc77c0ebd1356259e94f2ff.zip
If mod_mime_magic does not know the content-type, do not attempt to guess.
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
Diffstat (limited to 'modules/metadata')
-rw-r--r--modules/metadata/mod_mime_magic.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/modules/metadata/mod_mime_magic.c b/modules/metadata/mod_mime_magic.c
index 85f60fdedc..90b9816922 100644
--- a/modules/metadata/mod_mime_magic.c
+++ b/modules/metadata/mod_mime_magic.c
@@ -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;