helly           Fri Jan 23 16:33:57 2004 EDT

  Modified files:              
    /php-src/ext/spl    spl_directory.c 
  Log:
  Builtin recursion protection (by disallow to follow links by default).
  
  
http://cvs.php.net/diff.php/php-src/ext/spl/spl_directory.c?r1=1.20&r2=1.21&ty=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.20 php-src/ext/spl/spl_directory.c:1.21
--- php-src/ext/spl/spl_directory.c:1.20        Thu Jan  8 13:17:39 2004
+++ php-src/ext/spl/spl_directory.c     Fri Jan 23 16:33:56 2004
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.20 2004/01/08 18:17:39 helly Exp $ */
+/* $Id: spl_directory.c,v 1.21 2004/01/23 21:33:56 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -455,17 +455,27 @@
 }
 /* }}} */
 
-/* {{{ proto bool RecursiveDirectoryIterator::hasChildren()
+/* {{{ proto bool RecursiveDirectoryIterator::hasChildren([bool $allow_links = false])
    Returns whether current entry is a directory and not '.' or '..' */
 SPL_METHOD(RecursiveDirectoryIterator, hasChildren)
 {
+       zend_bool allow_links = 0;
        zval *object = getThis();
        spl_ce_dir_object *intern = 
(spl_ce_dir_object*)zend_object_store_get_object(object TSRMLS_CC);
        
        if (!strcmp(intern->entry.d_name, ".") || !strcmp(intern->entry.d_name, "..")) 
{
                RETURN_BOOL(0);
        } else {
+               if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", 
&allow_links) == FAILURE) {
+                       return;
+               }
                spl_dir_get_path_name(intern);
+               if (!allow_links) {
+                       php_stat(intern->path_name, intern->path_name_len, FS_IS_LINK, 
return_value TSRMLS_CC);
+                       if (zend_is_true(return_value)) {
+                               RETURN_BOOL(0);
+                       }
+               }
                php_stat(intern->path_name, intern->path_name_len, FS_IS_DIR, 
return_value TSRMLS_CC);
     }
 }

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

Reply via email to