akosut 96/03/22 21:16:55
Modified: src mod_mime.c
Log:
Fixed the revised find_ct() in mod_mime so that it reads from left to
right, not right to left. This means that, for example, foo.txt.html
will be tagged as text/html, as it is done in previous versions of
Apache, not text/plain.
Revision Changes Path
1.4 +9 -13 apache/src/mod_mime.c
Index: mod_mime.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_mime.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C3 -r1.3 -r1.4
*** mod_mime.c 1996/03/21 04:20:52 1.3
--- mod_mime.c 1996/03/23 05:16:53 1.4
***************
*** 192,226 ****
int find_ct(request_rec *r)
{
! int i;
! char *fn = pstrdup (r->pool, r->filename);
mime_dir_config *conf =
(mime_dir_config *)get_module_config(r->per_dir_config, &mime_module);
! char *type;
if (S_ISDIR(r->finfo.st_mode)) {
r->content_type = DIR_MAGIC_TYPE;
return OK;
}
!
/* Parse filename extensions, which can be in any order */
! while ((i = rind (fn, '.')) >= 0) {
! ++i;
/* Check for Content-Type */
! if ((type = table_get (conf->forced_types, &fn[i]))
! || (type = table_get (hash_buckets[hash(fn[i])], &fn[i])))
r->content_type = type;
/* Check for Content-Language */
! if ((type = table_get (conf->language_types, &fn[i])))
r->content_language = type;
/* Check for Content-Encoding */
! if ((type = table_get (conf->encoding_types, &fn[i])))
! r->content_encoding = type;
!
! fn[i-1] = '\0';
}
return OK;
--- 192,222 ----
int find_ct(request_rec *r)
{
! char *fn = strrchr(r->filename, '/');
mime_dir_config *conf =
(mime_dir_config *)get_module_config(r->per_dir_config, &mime_module);
! char *ext, *type;
if (S_ISDIR(r->finfo.st_mode)) {
r->content_type = DIR_MAGIC_TYPE;
return OK;
}
!
/* Parse filename extensions, which can be in any order */
! while ((ext = getword(r->pool, &fn, '.')) && *ext) {
/* Check for Content-Type */
! if ((type = table_get (conf->forced_types, ext))
! || (type = table_get (hash_buckets[hash(*ext)], ext)))
r->content_type = type;
/* Check for Content-Language */
! if ((type = table_get (conf->language_types, ext)))
r->content_language = type;
/* Check for Content-Encoding */
! if ((type = table_get (conf->encoding_types, ext)))
! r->content_encoding = type;
}
return OK;