[PHP-CVS] cvs: php-src /main/streams filter.c streams.c

2008-09-21 Thread Greg Beaver
cellog  Mon Sep 22 01:26:39 2008 UTC

  Modified files:  
/php-src/main/streams   filter.c streams.c 
  Log:
  MF52 fix Bug #46147: after stream seek, appending stream filter reads 
incorrect data
  
http://cvs.php.net/viewvc.cgi/php-src/main/streams/filter.c?r1=1.44r2=1.45diff_format=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.44 php-src/main/streams/filter.c:1.45
--- php-src/main/streams/filter.c:1.44  Mon Dec 31 07:12:18 2007
+++ php-src/main/streams/filter.c   Mon Sep 22 01:26:38 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.44 2007/12/31 07:12:18 sebastian Exp $ */
+/* $Id: filter.c,v 1.45 2008/09/22 01:26:38 cellog Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -461,15 +461,12 @@
stream-readpos = 0;
stream-writepos = 0;
} else if (status == PSFS_PASS_ON) {
-   /* Put any filtered data onto the readbuffer 
stack.
-  Previously read data has been at least 
partially consumed. */
-   stream-readpos += consumed;
-
-   if (stream-writepos == stream-readpos) {
-   /* Entirely consumed */
-   stream-writepos = 0;
-   stream-readpos = 0;
-   }
+   /* If any data is consumed, we cannot rely upon 
the existing read buffer,
+  as the filtered data must replace the 
existing data, so invalidate the cache */
+   /* note that changes here should be reflected in
+  
main/streams/streams.c::php_stream_fill_read_buffer */
+   stream-writepos = 0;
+   stream-readpos = 0;
 
while (brig_outp-head) {
bucket = brig_outp-head;
http://cvs.php.net/viewvc.cgi/php-src/main/streams/streams.c?r1=1.169r2=1.170diff_format=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.169 
php-src/main/streams/streams.c:1.170
--- php-src/main/streams/streams.c:1.169Tue Aug 26 16:06:23 2008
+++ php-src/main/streams/streams.c  Mon Sep 22 01:26:38 2008
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: streams.c,v 1.169 2008/08/26 16:06:23 dsp Exp $ */
+/* $Id: streams.c,v 1.170 2008/09/22 01:26:38 cellog Exp $ */
 
 #define _GNU_SOURCE
 #include php.h
@@ -455,6 +455,10 @@
php_stream_bucket_brigade brig_in = { NULL, NULL }, brig_out = 
{ NULL, NULL };
php_stream_bucket_brigade *brig_inp = brig_in, *brig_outp = 
brig_out, *brig_swap;
 
+   /* Invalidate the existing cache, otherwise reads can fail, see 
note in
+  main/streams/filter.c::_php_stream_filter_append */
+   stream-writepos = stream-readpos = 0;
+
/* allocate a buffer for reading chunks */
chunk_buf = emalloc(stream-chunk_size);
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main/streams filter.c

2007-01-15 Thread Antony Dovgal
tony2001Mon Jan 15 14:59:40 2007 UTC

  Modified files:  
/php-src/main/streams   filter.c 
  Log:
  include \0 to the hash
  it does matter because we use these strings in phpinfo()
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/streams/filter.c?r1=1.41r2=1.42diff_format=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.41 php-src/main/streams/filter.c:1.42
--- php-src/main/streams/filter.c:1.41  Mon Jan  1 09:29:35 2007
+++ php-src/main/streams/filter.c   Mon Jan 15 14:59:40 2007
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.41 2007/01/01 09:29:35 sebastian Exp $ */
+/* $Id: filter.c,v 1.42 2007/01/15 14:59:40 tony2001 Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -46,12 +46,12 @@
 /* API for registering GLOBAL filters */
 PHPAPI int php_stream_filter_register_factory(const char *filterpattern, 
php_stream_filter_factory *factory TSRMLS_DC)
 {
-   return zend_hash_add(stream_filters_hash, (char*)filterpattern, 
strlen(filterpattern), factory, sizeof(*factory), NULL);
+   return zend_hash_add(stream_filters_hash, (char*)filterpattern, 
strlen(filterpattern) + 1, factory, sizeof(*factory), NULL);
 }
 
 PHPAPI int php_stream_filter_unregister_factory(const char *filterpattern 
TSRMLS_DC)
 {
-   return zend_hash_del(stream_filters_hash, (char*)filterpattern, 
strlen(filterpattern));
+   return zend_hash_del(stream_filters_hash, (char*)filterpattern, 
strlen(filterpattern) + 1);
 }
 
 /* API for registering VOLATILE wrappers */
@@ -65,7 +65,7 @@
zend_hash_copy(FG(stream_filters), stream_filters_hash, NULL, 
tmpfactory, sizeof(php_stream_filter_factory));
}
 
-   return zend_hash_add(FG(stream_filters), (char*)filterpattern, 
strlen(filterpattern), factory, sizeof(*factory), NULL);
+   return zend_hash_add(FG(stream_filters), (char*)filterpattern, 
strlen(filterpattern) + 1, factory, sizeof(*factory), NULL);
 }
 
 /* Buckets */
@@ -317,7 +317,7 @@
 
n = strlen(filtername);

-   if (SUCCESS == zend_hash_find(filter_hash, (char*)filtername, n, 
(void**)factory)) {
+   if (SUCCESS == zend_hash_find(filter_hash, (char*)filtername, n + 1, 
(void**)factory)) {
filter = factory-create_filter(filtername, filterparams, 
persistent TSRMLS_CC);
} else if ((period = strrchr(filtername, '.'))) {
/* try a wildcard */
@@ -329,7 +329,7 @@
while (period  !filter) {
*period = '\0';
strcat(wildname, .*);
-   if (SUCCESS == zend_hash_find(filter_hash, wildname, 
strlen(wildname), (void**)factory)) {
+   if (SUCCESS == zend_hash_find(filter_hash, wildname, 
strlen(wildname) + 1, (void**)factory)) {
filter = factory-create_filter(filtername, 
filterparams, persistent TSRMLS_CC);
}
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main/streams filter.c

2006-12-25 Thread Dmitry Stogov
dmitry  Mon Dec 25 13:11:48 2006 UTC

  Modified files:  
/php-src/main/streams   filter.c 
  Log:
  Fixed heap overflow
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/streams/filter.c?r1=1.39r2=1.40diff_format=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.39 php-src/main/streams/filter.c:1.40
--- php-src/main/streams/filter.c:1.39  Tue Nov 21 15:47:44 2006
+++ php-src/main/streams/filter.c   Mon Dec 25 13:11:48 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.39 2006/11/21 15:47:44 tony2001 Exp $ */
+/* $Id: filter.c,v 1.40 2006/12/25 13:11:48 dmitry Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -323,7 +323,8 @@
/* try a wildcard */
char *wildname;
 
-   wildname = estrdup(filtername);
+   wildname = emalloc(n+3);
+   memcpy(wildname, filtername, n+1);
period = wildname + (period - filtername);
while (period  !filter) {
*period = '\0';

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main/streams filter.c

2006-10-11 Thread Sara Golemon
pollita Wed Oct 11 23:07:31 2006 UTC

  Modified files:  
/php-src/main/streams   filter.c 
  Log:
  Bugfix 38648: Don't assume all buckets are part of a brigade
  
http://cvs.php.net/viewvc.cgi/php-src/main/streams/filter.c?r1=1.37r2=1.38diff_format=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.37 php-src/main/streams/filter.c:1.38
--- php-src/main/streams/filter.c:1.37  Sun Oct  8 13:34:24 2006
+++ php-src/main/streams/filter.c   Wed Oct 11 23:07:30 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.37 2006/10/08 13:34:24 bjori Exp $ */
+/* $Id: filter.c,v 1.38 2006/10/11 23:07:30 pollita Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -281,12 +281,12 @@
 {
if (bucket-prev) {
bucket-prev-next = bucket-next;
-   } else {
+   } else if (bucket-brigade) {
bucket-brigade-head = bucket-next;
}
if (bucket-next) {
bucket-next-prev = bucket-prev;
-   } else {
+   } else if (bucket-brigade) {
bucket-brigade-tail = bucket-prev;
}
bucket-brigade = NULL;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main/streams filter.c

2006-05-19 Thread Antony Dovgal
tony2001Fri May 19 10:23:43 2006 UTC

  Modified files:  
/php-src/main/streams   filter.c 
  Log:
  initialize factory
  
  
http://cvs.php.net/viewcvs.cgi/php-src/main/streams/filter.c?r1=1.31r2=1.32diff_format=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.31 php-src/main/streams/filter.c:1.32
--- php-src/main/streams/filter.c:1.31  Thu Apr 13 18:14:14 2006
+++ php-src/main/streams/filter.c   Fri May 19 10:23:43 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.31 2006/04/13 18:14:14 tony2001 Exp $ */
+/* $Id: filter.c,v 1.32 2006/05/19 10:23:43 tony2001 Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -308,7 +308,7 @@
 PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, 
zval *filterparams, int persistent TSRMLS_DC)
 {
HashTable *filter_hash = (FG(stream_filters) ? FG(stream_filters) : 
stream_filters_hash);
-   php_stream_filter_factory *factory;
+   php_stream_filter_factory *factory = NULL;
php_stream_filter *filter = NULL;
int n;
char *period;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main/streams filter.c

2006-04-13 Thread Antony Dovgal
tony2001Thu Apr 13 18:14:14 2006 UTC

  Modified files:  
/php-src/main/streams   filter.c 
  Log:
  fix CS and prevent NULL dereference
  
  
http://cvs.php.net/viewcvs.cgi/php-src/main/streams/filter.c?r1=1.30r2=1.31diff_format=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.30 php-src/main/streams/filter.c:1.31
--- php-src/main/streams/filter.c:1.30  Thu Apr 13 04:41:08 2006
+++ php-src/main/streams/filter.c   Thu Apr 13 18:14:14 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.30 2006/04/13 04:41:08 pollita Exp $ */
+/* $Id: filter.c,v 1.31 2006/04/13 18:14:14 tony2001 Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -338,10 +338,12 @@
 
if (filter == NULL) {
/* TODO: these need correct docrefs */
-   if (factory == NULL)
+   if (factory == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, unable to 
locate filter \%s\, filtername);
-   else
+   } else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, unable to 
create or locate filter \%s\, filtername);
+   }
+   return NULL;
}
 
filter-name = pestrdup(filtername, filter-is_persistent);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main/streams filter.c

2006-03-24 Thread Andrei Zmievski
andrei  Fri Mar 24 21:25:44 2006 UTC

  Modified files:  
/php-src/main/streams   filter.c 
  Log:
  This is probably not a test..
  
  
http://cvs.php.net/viewcvs.cgi/php-src/main/streams/filter.c?r1=1.24r2=1.25diff_format=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.24 php-src/main/streams/filter.c:1.25
--- php-src/main/streams/filter.c:1.24  Fri Mar 24 20:21:48 2006
+++ php-src/main/streams/filter.c   Fri Mar 24 21:25:44 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.24 2006/03/24 20:21:48 pollita Exp $ */
+/* $Id: filter.c,v 1.25 2006/03/24 21:25:44 andrei Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -738,8 +738,8 @@
if (bucket-own_buf) {
pefree(bucket-buf.s, 
bucket-is_persistent);
}
-   bucket-buf_type == IS_UNICODE;
-   bucket-buf.u = (UChar*)\x00\x00;
+   bucket-buf_type = IS_UNICODE;
+   bucket-buf.u = EMPTY_STR;
bucket-own_buf = 0;
bucket-buflen = 0;
return SUCCESS;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main/streams filter.c streams.c

2004-09-13 Thread Sara Golemon
pollita Mon Sep 13 17:07:23 2004 EDT

  Modified files:  
/php-src/main/streams   streams.c filter.c 
  Log:
  Allocating hash tables should be done via macro, not directly
  
http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.65r2=1.66ty=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.65 php-src/main/streams/streams.c:1.66
--- php-src/main/streams/streams.c:1.65 Fri Sep 10 17:50:29 2004
+++ php-src/main/streams/streams.c  Mon Sep 13 17:07:22 2004
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: streams.c,v 1.65 2004/09/10 21:50:29 pollita Exp $ */
+/* $Id: streams.c,v 1.66 2004/09/13 21:07:22 pollita Exp $ */
 
 #define _GNU_SOURCE
 #include php.h
@@ -1414,7 +1414,7 @@
if (!FG(stream_wrappers)) {
php_stream_wrapper tmpwrapper;
 
-   FG(stream_wrappers) = emalloc(sizeof(HashTable));
+   ALLOC_HASHTABLE(FG(stream_wrappers));
zend_hash_init(FG(stream_wrappers), 0, NULL, NULL, 1);
zend_hash_copy(FG(stream_wrappers), url_stream_wrappers_hash, NULL, 
tmpwrapper, sizeof(php_stream_wrapper));
}
@@ -1427,7 +1427,7 @@
if (!FG(stream_wrappers)) {
php_stream_wrapper tmpwrapper;
 
-   FG(stream_wrappers) = emalloc(sizeof(HashTable));
+   ALLOC_HASHTABLE(FG(stream_wrappers));
zend_hash_init(FG(stream_wrappers), 0, NULL, NULL, 1);
zend_hash_copy(FG(stream_wrappers), url_stream_wrappers_hash, NULL, 
tmpwrapper, sizeof(php_stream_wrapper));
}
http://cvs.php.net/diff.php/php-src/main/streams/filter.c?r1=1.13r2=1.14ty=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.13 php-src/main/streams/filter.c:1.14
--- php-src/main/streams/filter.c:1.13  Mon Jun 21 17:08:05 2004
+++ php-src/main/streams/filter.c   Mon Sep 13 17:07:22 2004
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.13 2004/06/21 21:08:05 pollita Exp $ */
+/* $Id: filter.c,v 1.14 2004/09/13 21:07:22 pollita Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -60,7 +60,7 @@
if (!FG(stream_filters)) {
php_stream_filter_factory tmpfactory;
 
-   FG(stream_filters) = emalloc(sizeof(HashTable));
+   ALLOC_HASHTABLE(FG(stream_filters));
zend_hash_init(FG(stream_filters), 0, NULL, NULL, 1);
zend_hash_copy(FG(stream_filters), stream_filters_hash, NULL, 
tmpfactory, sizeof(php_stream_filter_factory));
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main/streams filter.c php_stream_filter_api.h

2004-05-26 Thread Wez Furlong
wez Wed May 26 17:19:21 2004 EDT

  Modified files:  
/php-src/main/streams   filter.c php_stream_filter_api.h 
  Log:
  Fix silly mistake.
  Thanks Antony :)
  
  
http://cvs.php.net/diff.php/php-src/main/streams/filter.c?r1=1.11r2=1.12ty=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.11 php-src/main/streams/filter.c:1.12
--- php-src/main/streams/filter.c:1.11  Wed Mar 31 22:52:34 2004
+++ php-src/main/streams/filter.c   Wed May 26 17:19:21 2004
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.11 2004/04/01 03:52:34 pollita Exp $ */
+/* $Id: filter.c,v 1.12 2004/05/26 21:19:21 wez Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -283,7 +283,7 @@
pefree(filter, filter-is_persistent);
 }
 
-PHPAPI void php_stream_filter_prepend(php_stream_filter_chain *chain, 
php_stream_filter *filter TSRMLS_DC)
+PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, 
php_stream_filter *filter TSRMLS_DC)
 {
filter-next = chain-head;
filter-prev = NULL;
@@ -297,7 +297,7 @@
filter-chain = chain;
 }
 
-PHPAPI void php_stream_filter_append(php_stream_filter_chain *chain, 
php_stream_filter *filter TSRMLS_DC)
+PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, 
php_stream_filter *filter TSRMLS_DC)
 {
php_stream *stream = chain-stream;
 
http://cvs.php.net/diff.php/php-src/main/streams/php_stream_filter_api.h?r1=1.8r2=1.9ty=u
Index: php-src/main/streams/php_stream_filter_api.h
diff -u php-src/main/streams/php_stream_filter_api.h:1.8 
php-src/main/streams/php_stream_filter_api.h:1.9
--- php-src/main/streams/php_stream_filter_api.h:1.8Wed Mar 31 18:48:59 2004
+++ php-src/main/streams/php_stream_filter_api.hWed May 26 17:19:21 2004
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: php_stream_filter_api.h,v 1.8 2004/03/31 23:48:59 pollita Exp $ */
+/* $Id: php_stream_filter_api.h,v 1.9 2004/05/26 21:19:21 wez Exp $ */
 
 /* The filter API works on the principle of Bucket-Brigades.  This is
  * partially inspired by the Apache 2 method of doing things, although
@@ -129,8 +129,8 @@
 END_EXTERN_C()
 #define php_stream_filter_alloc(fops, thisptr, persistent) 
_php_stream_filter_alloc((fops), (thisptr), (persistent) STREAMS_CC TSRMLS_CC)
 #define php_stream_filter_alloc_rel(fops, thisptr, persistent) 
_php_stream_filter_alloc((fops), (thisptr), (persistent) STREAMS_REL_CC TSRMLS_CC)
-#define php_stream_fitler_prepend(chain, filter) _php_stream_filter_prepend((chain), 
(filter) TSRMLS_CC)
-#define php_stream_fitler_append(chain, filter) _php_stream_filter_append((chain), 
(filter) TSRMLS_CC)
+#define php_stream_filter_prepend(chain, filter) _php_stream_filter_prepend((chain), 
(filter) TSRMLS_CC)
+#define php_stream_filter_append(chain, filter) _php_stream_filter_append((chain), 
(filter) TSRMLS_CC)
 
 #define php_stream_is_filtered(stream) ((stream)-readfilters.head || 
(stream)-writefilters.head)
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main/streams filter.c

2004-03-31 Thread Sara Golemon
pollita Wed Mar 31 22:52:35 2004 EDT

  Modified files:  
/php-src/main/streams   filter.c 
  Log:
  Only wind filters when appending to the read chain.
  
http://cvs.php.net/diff.php/php-src/main/streams/filter.c?r1=1.10r2=1.11ty=u
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.10 php-src/main/streams/filter.c:1.11
--- php-src/main/streams/filter.c:1.10  Wed Mar 31 18:48:59 2004
+++ php-src/main/streams/filter.c   Wed Mar 31 22:52:34 2004
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.10 2004/03/31 23:48:59 pollita Exp $ */
+/* $Id: filter.c,v 1.11 2004/04/01 03:52:34 pollita Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -311,7 +311,7 @@
chain-tail = filter;
filter-chain = chain;
 
-   if ((stream-writepos - stream-readpos)  0) {
+   if ((stream-readfilters) == chain  (stream-writepos - stream-readpos)  
0) {
/* Let's going ahead and wind anything in the buffer through this 
filter */
php_stream_bucket_brigade brig_in = { NULL, NULL }, brig_out = { NULL, 
NULL };
php_stream_bucket_brigade *brig_inp = brig_in, *brig_outp = brig_out;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php-src /main/streams filter.c

2003-10-28 Thread Sara Golemon
pollita Tue Oct 28 16:53:00 2003 EDT

  Modified files:  
/php-src/main/streams   filter.c 
  Log:
  Extend Filter matching to check wildcards at multiple levels.
  Ex:  foo.bar.baz.bomb
  Searches:
   foo.bar.baz.bomb itself,
   foo.bar.baz.*,
   foo.bar.*, and
   foo.*
  
  Also changed tempvar char wildcard[128]; to an estrdup() to
  deal with potential filternames longer than 127 bytes.
  
  
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.6 php-src/main/streams/filter.c:1.7
--- php-src/main/streams/filter.c:1.6   Tue Jun 10 16:03:42 2003
+++ php-src/main/streams/filter.c   Tue Oct 28 16:52:59 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.6 2003/06/10 20:03:42 imajes Exp $ */
+/* $Id: filter.c,v 1.7 2003/10/28 21:52:59 pollita Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -217,8 +217,8 @@
 
 
 /* We allow very simple pattern matching for filter factories:
- * if charset.utf-8/sjis is requested, we search first for an exact
- * match. If that fails, we try charset.*.
+ * if convert.charset.utf-8/sjis is requested, we search first for an exact
+ * match. If that fails, we try convert.charset.*, then convert.*
  * This means that we don't need to clog up the hashtable with a zillion
  * charsets (for example) but still be able to provide them all as filters */
 PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval 
*filterparams, int persistent TSRMLS_DC)
@@ -232,16 +232,23 @@

if (SUCCESS == zend_hash_find(stream_filters_hash, (char*)filtername, n, 
(void**)factory)) {
filter = factory-create_filter(filtername, filterparams, persistent 
TSRMLS_CC);
-   } else if ((period = strchr(filtername, '.'))) {
+   } else if ((period = strrchr(filtername, '.'))) {
/* try a wildcard */
-   char wildname[128];
+   char *wildname;
 
-   PHP_STRLCPY(wildname, filtername, sizeof(wildname) - 1, 
period-filtername + 1);
-   strcat(wildname, *);
-   
-   if (SUCCESS == zend_hash_find(stream_filters_hash, wildname, 
strlen(wildname), (void**)factory)) {
-   filter = factory-create_filter(filtername, filterparams, 
persistent TSRMLS_CC);
+   wildname = estrdup(filtername);
+   period = wildname + (period - filtername);
+   while (period) {
+   *period = '\0';
+   strcat(wildname, .*);
+   if (SUCCESS == zend_hash_find(stream_filters_hash, wildname, 
strlen(wildname), (void**)factory)) {
+   filter = factory-create_filter(filtername, 
filterparams, persistent TSRMLS_CC);
+   }
+
+   *period = '\0';
+   period = strrchr(wildname, '.');
}
+   efree(wildname);
}
 
if (filter == NULL) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src /main/streams filter.c

2003-10-28 Thread Sara Golemon
pollita Tue Oct 28 18:29:17 2003 EDT

  Modified files:  
/php-src/main/streams   filter.c 
  Log:
  Stop looking once we've found a matching filter.
  
Index: php-src/main/streams/filter.c
diff -u php-src/main/streams/filter.c:1.7 php-src/main/streams/filter.c:1.8
--- php-src/main/streams/filter.c:1.7   Tue Oct 28 16:52:59 2003
+++ php-src/main/streams/filter.c   Tue Oct 28 18:29:16 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: filter.c,v 1.7 2003/10/28 21:52:59 pollita Exp $ */
+/* $Id: filter.c,v 1.8 2003/10/28 23:29:16 pollita Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -238,7 +238,7 @@
 
wildname = estrdup(filtername);
period = wildname + (period - filtername);
-   while (period) {
+   while (period  !filter) {
*period = '\0';
strcat(wildname, .*);
if (SUCCESS == zend_hash_find(stream_filters_hash, wildname, 
strlen(wildname), (void**)factory)) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php