--- httpd-2.0.35/modules/metadata/mod_expires.c Wed Mar 13 20:47:52 2002 +++ httpd-2.0.35/modules/metadata/mod_expires.c Sat Apr 6 17:27:02 2002 @@ -455,7 +455,7 @@ static int add_expires(request_rec *r) if (r->content_type == NULL) code = NULL; else - code = (char *) apr_table_get(conf->expiresbytype, + code = (char *) apr_table_match(conf->expiresbytype, ap_field_noparam(r->pool, r->content_type)); if (code == NULL) { --- httpd-2.0.35/srclib/apr/include/apr_strings.h Wed Mar 13 20:39:15 2002 +++ httpd-2.0.35/srclib/apr/include/apr_strings.h Sat Apr 6 23:59:38 2002 @@ -322,6 +322,23 @@ APR_DECLARE(char *) apr_off_t_toa(apr_po * @remark All negative sizes report ' - ', apr_strfsize only formats positive values. */ APR_DECLARE(char *) apr_strfsize(apr_off_t size, char *buf); + +/** + * Determine if a string matches a patterm containing the wildcards '?' or '*' + * @param str The string to check + * @param exp The pattern to match against + * @return 1 if the two strings match, 0 otherwise + */ +APR_DECLARE(int) apr_strcmp_match(const char *str, const char *exp); +/** + * Determine if a string matches a patterm containing the wildcards '?' or '*', + * ignoring case + * @param str The string to check + * @param exp The pattern to match against + * @return 1 if the two strings match, 0 otherwise + */ +APR_DECLARE(int) apr_strcasecmp_match(const char *str, const char *exp); + /** @} */ #ifdef __cplusplus } --- httpd-2.0.35/srclib/apr/include/apr_tables.h Wed Mar 13 20:39:15 2002 +++ httpd-2.0.35/srclib/apr/include/apr_tables.h Sat Apr 6 17:27:02 2002 @@ -260,6 +260,18 @@ APR_DECLARE(void) apr_table_clear(apr_ta APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key); /** + * Get the value associated with a given key from the table. After this call, + * The data is still in the table + * This allows wildcards in the table keys, so a search for, eg, "image/gif" + * may return the value for the key "image/*" in the table. + * @param t The table to search for the key + * @param key The key to search for + * @return The value associated with the key + * @deffunc const char *apr_table_match(const apr_table_t *t, const char *key) + */ +APR_DECLARE(const char *) apr_table_match(const apr_table_t *t, const char *key); + +/** * Add a key/value pair to a table, if another element already exists with the * same key, this will over-write the old data. * @param t The table to add the data to. --- httpd-2.0.35/srclib/apr/strings/Makefile.in Wed May 23 15:15:43 2001 +++ httpd-2.0.35/srclib/apr/strings/Makefile.in Sun Apr 7 00:01:06 2002 @@ -5,7 +5,8 @@ TARGETS = \ apr_strnatcmp.lo \ apr_strings.lo \ apr_fnmatch.lo \ - apr_strtok.lo + apr_strtok.lo \ + apr_strmatch.lo # bring in rules.mk for standard functionality @INCLUDE_RULES@ --- httpd-2.0.35/srclib/apr/strings/apr_strmatch.c Thu Jan 1 00:00:00 1970 +++ httpd-2.0.35/srclib/apr/strings/apr_strmatch.c Sun Apr 7 00:21:10 2002 @@ -0,0 +1,111 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + +#include "apr.h" +#include "apr_strings.h" +#include "apr_lib.h" + +/* Copied from server/util.c, changing ap_ to apr_ */ +/* Match = 0, NoMatch = 1, Abort = -1 + * Based loosely on sections of wildmat.c by Rich Salz + * Hmmm... shouldn't this really go component by component? + */ +APR_DECLARE(int) apr_strcmp_match(const char *str, const char *exp) +{ + int x, y; + + for (x = 0, y = 0; exp[y]; ++y, ++x) { + if ((!str[x]) && (exp[y] != '*')) + return -1; + if (exp[y] == '*') { + while (exp[++y] == '*'); + if (!exp[y]) + return 0; + while (str[x]) { + int ret; + if ((ret = apr_strcmp_match(&str[x++], &exp[y])) != 1) + return ret; + } + return -1; + } + else if ((exp[y] != '?') && (str[x] != exp[y])) + return 1; + } + return (str[x] != '\0'); +} + +APR_DECLARE(int) apr_strcasecmp_match(const char *str, const char *exp) +{ + int x, y; + + for (x = 0, y = 0; exp[y]; ++y, ++x) { + if ((!str[x]) && (exp[y] != '*')) + return -1; + if (exp[y] == '*') { + while (exp[++y] == '*'); + if (!exp[y]) + return 0; + while (str[x]) { + int ret; + if ((ret = apr_strcasecmp_match(&str[x++], &exp[y])) != 1) + return ret; + } + return -1; + } + else if ((exp[y] != '?') && (apr_tolower(str[x]) != apr_tolower(exp[y]))) + return 1; + } + return (str[x] != '\0'); +} + --- httpd-2.0.35/srclib/apr/tables/apr_tables.c Wed Mar 13 20:39:27 2002 +++ httpd-2.0.35/srclib/apr/tables/apr_tables.c Sun Apr 7 00:07:59 2002 @@ -412,6 +412,27 @@ APR_DECLARE(const char *) apr_table_get( return NULL; } +APR_DECLARE(const char *) apr_table_match(const apr_table_t *t, const char *key) +{ + apr_table_entry_t *elts = (apr_table_entry_t *) t->a.elts; + int i; + apr_uint32_t checksum; + + if (key == NULL) { + return NULL; + } + + COMPUTE_KEY_CHECKSUM(key, checksum); + for (i = 0; i < t->a.nelts; ++i) { + if (((checksum == elts[i].key_checksum) && !strcasecmp(elts[i].key, key)) + || !apr_strcasecmp_match(key, elts[i].key)) { + return elts[i].val; + } + } + + return NULL; +} + APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key, const char *val) {