mod_mime.c revision e9fa5a00f39f6aabbc5dcd776c5bc6bd0638f955
792N/A/* ==================================================================== 792N/A * The Apache Software License, Version 1.1 792N/A * Copyright (c) 2000-2001 The Apache Software Foundation. All rights 792N/A * Redistribution and use in source and binary forms, with or without 792N/A * modification, are permitted provided that the following conditions 919N/A * 1. Redistributions of source code must retain the above copyright 919N/A * notice, this list of conditions and the following disclaimer. 919N/A * 2. Redistributions in binary form must reproduce the above copyright 919N/A * notice, this list of conditions and the following disclaimer in 919N/A * the documentation and/or other materials provided with the 919N/A * 3. The end-user documentation included with the redistribution, 919N/A * if any, must include the following acknowledgment: 919N/A * "This product includes software developed by the 919N/A * Alternately, this acknowledgment may appear in the software itself, 919N/A * if and wherever such third-party acknowledgments normally appear. 792N/A * 4. The names "Apache" and "Apache Software Foundation" must 792N/A * not be used to endorse or promote products derived from this 792N/A * software without prior written permission. For written 792N/A * permission, please contact apache@apache.org. 792N/A * 5. Products derived from this software may not be called "Apache", 792N/A * nor may "Apache" appear in their name, without prior written 792N/A * permission of the Apache Software Foundation. 911N/A * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 911N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 911N/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 911N/A * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 792N/A * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 792N/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 792N/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 792N/A * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 792N/A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 930N/A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 924N/A * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 792N/A * ==================================================================== 792N/A * This software consists of voluntary contributions made by many 792N/A * individuals on behalf of the Apache Software Foundation. For more 792N/A * information on the Apache Software Foundation, please see 792N/A * Portions of this software are based upon public domain software 792N/A * originally written at the National Center for Supercomputing Applications, 792N/A * University of Illinois, Urbana-Champaign. 792N/A/* XXXX - fix me / EBCDIC 792N/A * there was a cludge here which would use its 792N/A * own version apr_isascii(). Indicating that 792N/A * on some platforms that might be needed. 792N/A * #define OS_ASC(c) (c) -- for mere mortals 792N/A * #define OS_ASC(c) (ebcdic2ascii[c]) -- for dino's 792N/A * #define apr_isascii(c) ((OS_ASC(c) & 0x80) == 0) 792N/A/* XXXXX - fix me - See note with NOT_PROXY 792N/A/* Information to which an extension can be mapped 792N/A * extension_info structure */ 792N/A /* Due to the FUD about JS and charsets '(',
')',
'<',
'>',
'@',
',',
';',
':',
'\\',
'"',
'/',
'[',
']',
'?',
'=',
* Overlay one hash table of extension_mappings onto another /* Member is the offset within an extension_info of the pointer to reset /* We may not be merging the tables, but if we potentially will change * an exinfo member, then we are about to trounce it anyways. * We must have a copy for safety. * Note handler names are un-added with each per_dir_config merge. * This keeps the association from being inherited, but not * from being re-added at a subordinate level. /* The sole bit of server configuration that the MIME module has is * the name of its config file, so... "a charset (e.g., iso-2022-jp), followed by one or more file extensions"),
"an encoding (e.g., gzip), followed by one or more file extensions"),
"a handler name followed by one or more file extensions"),
"input filter name (or ; delimited names) followed by one or more file extensions"),
"a language (e.g., fr), followed by one or more file extensions"),
"output filter name (or ; delimited names) followed by one or more file extensions"),
"a mime type followed by one or more file extensions"),
"language to use for documents with no other language file extension"),
"one or more file extensions"),
"one or more file extensions"),
"one or more file extensions"),
"one or more file extensions"),
"one or more file extensions"),
"one or more file extensions"),
"one or more file extensions"),
"the MIME types config file"),
/* delete prefixed white space */ for (; *s ==
' ' || *s ==
'\t' || *s ==
'\n'; s++);
/* delete postfixed white space */ for (
tp = s; *
tp !=
'\0';
tp++);
for (
tp--;
tp != s && (*
tp ==
' ' || *
tp ==
'\t' || *
tp ==
'\n');
tp--) {
if (((s +
1) !=
NULL) && (*s ==
'\\')) {
"mod_mime: analyze_ct: cannot get media type from '%s'",
"Cannot get media subtype.");
for (; *
cp !=
';' && *
cp !=
'\0';
cp++)
"Cannot get media subtype.");
"Cannot get media parameter.");
else if (*
cp ==
' ' || *
cp ==
'\t' || *
cp ==
'\n') {
"Cannot get media parameter.");
"Cannot get media parameter.");
"Cannot get media parameter.");
while (*
cp ==
' ' || *
cp ==
'\t' || *
cp ==
'\n') {
if (*
cp !=
';' && *
cp !=
'\0') {
"Cannot get media parameter.");
"Cannot get media parameter.");
else if (*
cp ==
'\0' || *
cp ==
';') {
"Cannot get media parameter.");
"Cannot get media parameter.");
* find_ct is the hook routine for determining content-type and other * MIME-related metadata. It assumes that r->filename has already been * set and stat has been called for r->finfo. It also assumes that the * non-path base file name is not the empty string unless it is a dir. /* Always drop the path leading up to the file name. /* The exception list keeps track of those filename components that * are not associated with extensions indicating metadata. * The base name is always the first exception (i.e., "txt.html" has * a basename of "txt" even though it might look like an extension). /* Parse filename extensions which can be in any order /* We have a basic problem that folks on case-crippled systems * expect anything and everything to succeed /* XXX should eliminate duplicate entities */ /* The following extensions are not 'Found'. That is, they don't * make any contribution to metadata negotation, so they must have * been explicitly requested by name. /* XXX Two significant problems; 1, we don't check to see if we are * setting redundant filters. 2, we insert these in the types config * hook, which may be too early (dunno.) * Need to set a notes entry on r for unrecognized elements. * Somebody better claim them! If we did absolutely nothing, * skip the notes to alert mod_negotiation we are clueless. /* Set default language, if none was specified by the extensions * and we have a DefaultLanguage setting in force * this hook seems redundant ... is there any reason a type checker isn't * allowed to do this already? I'd think that fixups in general would be * the last opportunity to get the filters right. * ap_hook_insert_filter(mime_insert_filters,NULL,NULL,APR_HOOK_MIDDLE); NULL,
/* create per-server config structure */ NULL,
/* merge per-server config structures */