From: Sara Golemon Date: Wed, 29 Oct 2003 00:19:57 +0000 (+0000) Subject: Allow userspace filters to use wildcards X-Git-Tag: RELEASE_2_0_0RC1~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=70f4a0c9ecfd8bd5ce5a424a3004dec607d0ea67;p=php Allow userspace filters to use wildcards --- diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 891055bbd4..64241d6147 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -246,9 +246,36 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, /* determine the classname/class entry */ if (FAILURE == zend_hash_find(BG(user_filter_map), (char*)filtername, strlen(filtername), (void**)&fdat)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "Err, filter \"%s\" is not in the user-filter map, but somehow the user-filter-factory was invoked for it!?", filtername); - return NULL; + char *period; + + /* Userspace Filters using ambiguous wildcards could cause problems. + i.e.: myfilter.foo.bar will always call into myfilter.foo.* + never seeing myfilter.* + TODO: Allow failed userfilter creations to continue + scanning through the list */ + if ((period = strrchr(filtername, '.'))) { + char *wildcard; + + /* Search for wildcard matches instead */ + wildcard = estrdup(filtername); + period = wildcard + (period - filtername); + while (period) { + *period = '\0'; + strcat(wildcard, ".*"); + if (SUCCESS == zend_hash_find(BG(user_filter_map), wildcard, strlen(wildcard), (void**)&fdat)) { + period = NULL; + } else { + *period = '\0'; + period = strrchr(wildcard, '.'); + } + } + efree(wildcard); + } + if (fdat == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "Err, filter \"%s\" is not in the user-filter map, but somehow the user-filter-factory was invoked for it!?", filtername); + return NULL; + } } /* bind the classname to the actual class */