You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by je...@apache.org on 2003/05/21 06:42:11 UTC
cvs commit: httpd-2.0/modules/metadata mod_mime_magic.c
jerenkrantz 2003/05/20 21:42:11
Modified: . Tag: APACHE_2_0_BRANCH CHANGES
modules/metadata Tag: APACHE_2_0_BRANCH mod_mime_magic.c
Log:
If mod_mime_magic does not know the content-type, do not attempt to guess.
PR: 16908
Submitted by: Andrew Gapon <ag...@telcordia.com>
Reviewed by: Justin Erenkrantz, nd, jim
Revision Changes Path
No revision
No revision
1.988.2.107 +3 -0 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.988.2.106
retrieving revision 1.988.2.107
diff -u -u -r1.988.2.106 -r1.988.2.107
--- CHANGES 21 May 2003 04:38:55 -0000 1.988.2.106
+++ CHANGES 21 May 2003 04:42:09 -0000 1.988.2.107
@@ -1,5 +1,8 @@
Changes with Apache 2.0.46
+ *) If mod_mime_magic does not know the content-type, do not attempt to
+ guess. PR 16908. [Andrew Gapon <ag...@telcordia.com>]
+
*) ssl session caching(shmht) : Fix a SEGV problem with SHMHT session
caching. PR 17864.
[Andreas Leimbacher <an...@yahoo.de>, Madhusudan Mathihalli]
No revision
No revision
1.59.2.2 +18 -20 httpd-2.0/modules/metadata/mod_mime_magic.c
Index: mod_mime_magic.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_mime_magic.c,v
retrieving revision 1.59.2.1
retrieving revision 1.59.2.2
diff -u -u -r1.59.2.1 -r1.59.2.2
--- mod_mime_magic.c 3 Feb 2003 17:31:46 -0000 1.59.2.1
+++ mod_mime_magic.c 21 May 2003 04:42:10 -0000 1.59.2.2
@@ -257,7 +257,7 @@
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 @@
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 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 @@
}
/* 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 @@
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;