cvs: php-src /ext/standard user_filters.c

From: Date: Wed, 29 Oct 2003 00:19:58 +0000
Subject: cvs: php-src /ext/standard user_filters.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-24344@lists.php.net to get a copy of this message
pollita Tue Oct 28 19:19:58 2003 EDT Modified files: /php-src/ext/standard user_filters.c Log: Allow userspace filters to use wildcards Index: php-src/ext/standard/user_filters.c diff -u php-src/ext/standard/user_filters.c:1.21 php-src/ext/standard/user_filters.c:1.22 --- php-src/ext/standard/user_filters.c:1.21 Tue Oct 28 18:56:57 2003 +++ php-src/ext/standard/user_filters.c Tue Oct 28 19:19:57 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: user_filters.c,v 1.21 2003/10/28 23:56:57 pollita Exp $ */ +/* $Id: user_filters.c,v 1.22 2003/10/29 00:19:57 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -246,9 +246,36 @@ /* 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 */

« previous php.cvs (#24344) next »