helly           Mon Aug  2 04:27:58 2004 EDT

  Modified files:              
    /ZendEngine2        zend_compile.c zend_compile.h zend_execute_API.c 
    /php-src/ext/mbstring/tests htmlent.phpt 
    /php-src/tests/classes      ctor_failure.phpt 
  Log:
  MFB: Enforce protocol on magic methods/functions
  
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.571&r2=1.572&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.571 ZendEngine2/zend_compile.c:1.572
--- ZendEngine2/zend_compile.c:1.571    Thu Jul 29 13:45:29 2004
+++ ZendEngine2/zend_compile.c  Mon Aug  2 04:27:57 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.c,v 1.571 2004/07/29 17:45:29 pollita Exp $ */
+/* $Id: zend_compile.c,v 1.572 2004/08/02 08:27:57 helly Exp $ */
 
 #include "zend_language_parser.h"
 #include "zend.h"
@@ -1089,16 +1089,37 @@
 
 void zend_do_end_function_declaration(znode *function_token TSRMLS_DC)
 {
+       char lcname[16];
+       int name_len;
+
        zend_do_extended_info(TSRMLS_C);
        zend_do_return(NULL, 0 TSRMLS_CC);
        zend_do_handle_exception(TSRMLS_C);
 
        pass_two(CG(active_op_array) TSRMLS_CC);
 
-       if (CG(active_class_entry)
-               && !strcmp(CG(active_op_array)->function_name, ZEND_CLONE_FUNC_NAME)
-               && CG(active_op_array)->num_args != 0) {
-               zend_error(E_COMPILE_ERROR, "The clone method cannot accept any 
arguments");
+       /* we don't care if the function name is longer, in fact lowercasing only 
+        * the beginning of the name speeds up th echeck process */
+       name_len = strlen(CG(active_op_array)->function_name);
+       zend_str_tolower_copy(lcname, CG(active_op_array)->function_name, 
MIN(name_len, sizeof(lcname)-1));
+       lcname[sizeof(lcname)-1] = '\0'; // zend_str_tolower_copy won't necessarily 
set the zero byte
+
+       if (CG(active_class_entry)) {
+               if (name_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME) - 1 && 
!strcmp(lcname, ZEND_DESTRUCTOR_FUNC_NAME) && CG(active_op_array)->num_args != 0) {
+                       zend_error(E_COMPILE_ERROR, "Destuctor %s::%s() cannot take 
arguments", CG(active_class_entry)->name, ZEND_DESTRUCTOR_FUNC_NAME);
+               } else if (name_len == sizeof(ZEND_CLONE_FUNC_NAME) - 1 && 
!strcmp(lcname, ZEND_CLONE_FUNC_NAME) && CG(active_op_array)->num_args != 0) {
+                       zend_error(E_COMPILE_ERROR, "Method %s::%s() cannot accept any 
arguments", CG(active_class_entry)->name, ZEND_CLONE_FUNC_NAME);
+               } else if (name_len == sizeof(ZEND_GET_FUNC_NAME) - 1 && 
!strcmp(lcname, ZEND_GET_FUNC_NAME) && CG(active_op_array)->num_args != 1) {
+                       zend_error(E_COMPILE_ERROR, "Method %s::%s() must take exactly 
1 argument", CG(active_class_entry)->name, ZEND_GET_FUNC_NAME);
+               } else if (name_len == sizeof(ZEND_SET_FUNC_NAME) - 1 && 
!strcmp(lcname, ZEND_SET_FUNC_NAME) && CG(active_op_array)->num_args != 2) {
+                       zend_error(E_COMPILE_ERROR, "Method %s::%s() must take exactly 
2 arguments", CG(active_class_entry)->name, ZEND_SET_FUNC_NAME);
+               } else if (name_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && 
!strcmp(lcname, ZEND_CALL_FUNC_NAME) && CG(active_op_array)->num_args != 2) {
+                       zend_error(E_COMPILE_ERROR, "Method %s::%s() must take exactly 
2 arguments", CG(active_class_entry)->name, ZEND_CALL_FUNC_NAME);
+               }
+       } else {
+               if (name_len == sizeof(ZEND_AUTOLOAD_FUNC_NAME) - 1 && !strcmp(lcname, 
ZEND_AUTOLOAD_FUNC_NAME) && CG(active_op_array)->num_args != 1) {
+                       zend_error(E_COMPILE_ERROR, "%s() must take exactly 1 
argument", ZEND_AUTOLOAD_FUNC_NAME);
+               }               
        }
 
        CG(active_op_array)->line_end = zend_get_compiled_lineno(TSRMLS_C);
@@ -1116,10 +1137,6 @@
        zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
        zend_arg_info *cur_arg_info;
 
-       if (CG(active_class_entry) && CG(active_class_entry)->destructor == 
(zend_function *) CG(active_op_array))
-       {
-               zend_error(E_COMPILE_ERROR, "Destuctor %s::%s() cannot take 
arguments", CG(active_class_entry)->name, CG(active_op_array)->function_name);
-       }
        CG(active_op_array)->num_args++;
        opline->opcode = op;
        opline->result = *var;
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.286&r2=1.287&ty=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.286 ZendEngine2/zend_compile.h:1.287
--- ZendEngine2/zend_compile.h:1.286    Thu Jul 29 13:45:29 2004
+++ ZendEngine2/zend_compile.h  Mon Aug  2 04:27:57 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.h,v 1.286 2004/07/29 17:45:29 pollita Exp $ */
+/* $Id: zend_compile.h,v 1.287 2004/08/02 08:27:57 helly Exp $ */
 
 #ifndef ZEND_COMPILE_H
 #define ZEND_COMPILE_H
@@ -840,6 +840,7 @@
 #define ZEND_GET_FUNC_NAME          "__get"
 #define ZEND_SET_FUNC_NAME          "__set"
 #define ZEND_CALL_FUNC_NAME         "__call"
+#define ZEND_AUTOLOAD_FUNC_NAME     "__autoload"
 
 #endif /* ZEND_COMPILE_H */
 
http://cvs.php.net/diff.php/ZendEngine2/zend_execute_API.c?r1=1.290&r2=1.291&ty=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.290 ZendEngine2/zend_execute_API.c:1.291
--- ZendEngine2/zend_execute_API.c:1.290        Fri Jul 30 17:00:37 2004
+++ ZendEngine2/zend_execute_API.c      Mon Aug  2 04:27:57 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute_API.c,v 1.290 2004/07/30 21:00:37 andi Exp $ */
+/* $Id: zend_execute_API.c,v 1.291 2004/08/02 08:27:57 helly Exp $ */
 
 #include <stdio.h>
 #include <signal.h>
@@ -923,7 +923,7 @@
                return FAILURE;
        }
 
-       ZVAL_STRINGL(&autoload_function, "__autoload", sizeof("__autoload")-1,  0);
+       ZVAL_STRINGL(&autoload_function, ZEND_AUTOLOAD_FUNC_NAME, 
sizeof(ZEND_AUTOLOAD_FUNC_NAME)-1,  0);
 
        INIT_PZVAL(class_name_ptr);
        ZVAL_STRINGL(class_name_ptr, name, name_length, 0);
@@ -944,7 +944,7 @@
 
        if (EG(exception)) {
                free_alloca(lc_name);
-               zend_error(E_ERROR, "__autoload(%s) threw an exception of type '%s'", 
name, Z_OBJCE_P(EG(exception))->name);
+               zend_error(E_ERROR, "Function %s(%s) threw an exception of type '%s'", 
ZEND_AUTOLOAD_FUNC_NAME, name, Z_OBJCE_P(EG(exception))->name);
                return FAILURE;
        }
        EG(exception) = exception;
http://cvs.php.net/diff.php/php-src/ext/mbstring/tests/htmlent.phpt?r1=1.4&r2=1.5&ty=u
Index: php-src/ext/mbstring/tests/htmlent.phpt
diff -u php-src/ext/mbstring/tests/htmlent.phpt:1.4 
php-src/ext/mbstring/tests/htmlent.phpt:1.5
--- php-src/ext/mbstring/tests/htmlent.phpt:1.4 Thu Oct 23 23:31:56 2003
+++ php-src/ext/mbstring/tests/htmlent.phpt     Mon Aug  2 04:27:57 2004
@@ -6,18 +6,19 @@
        extension_loaded('mbstring') or die('skip mbstring not available'); 
 ?>
 --INI--
+output_buffering=4096
 output_handler=mb_output_handler
 zlib.output_compression=
-arg_separator.input="x"
+arg_separator.input=x
 error_reporting=0
 mbstring.http_input=HTML-ENTITIES
-mbstring.internal_encoding=UTF8
+mbstring.internal_encoding=UTF-8
 mbstring.http_output=HTML-ENTITIES
 mbstring.encoding_translation=1
 --FILE--
 <?php
 // enable output encoding through output handler
-ob_start("mb_output_handler");
+//ob_start("mb_output_handler");
 // &#64... are must be decoded on input these are not reencoded on output. 
 // If you see &#64;&#65;&#66; on output this means input encoding fails.
 // If you do not see &auml;... on output this means output encoding fails.
@@ -27,9 +28,11 @@
 ?>
 <?php echo mb_http_input('l').'>'.mb_internal_encoding().'>'.mb_http_output();?>
 
-<?php 
mb_parse_str("test=&&;&&#64;&#65;&#66;&#128;&#129;&#130;&auml;&ouml;&uuml;&euro;&lang;&rang;");
-echo "test='$test'";
+<?php 
mb_parse_str("test=&#64;&#65;&#66;&#128;&#129;&#130;&auml;&ouml;&uuml;&euro;&lang;&rang;",
 $test);
+print_r($test['test']);
 ?>
+===DONE===
 --EXPECT--
 HTML-ENTITIES>UTF-8>HTML-ENTITIES
-test='&&;&@AB&#128;&#129;&#130;&auml;&ouml;&uuml;&euro;&lang;&rang;'
\ No newline at end of file
+test='&&;&@AB&#128;&#129;&#130;&auml;&ouml;&uuml;&euro;&lang;&rang;'
+===DONE===
http://cvs.php.net/diff.php/php-src/tests/classes/ctor_failure.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/tests/classes/ctor_failure.phpt
diff -u php-src/tests/classes/ctor_failure.phpt:1.1 
php-src/tests/classes/ctor_failure.phpt:1.2
--- php-src/tests/classes/ctor_failure.phpt:1.1 Sun Jul 25 15:21:21 2004
+++ php-src/tests/classes/ctor_failure.phpt     Mon Aug  2 04:27:57 2004
@@ -1,5 +1,5 @@
 --TEST--
-Do not call destructors if constructor fails
+ZE2 Do not call destructors if constructor fails
 --FILE--
 <?php
 

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

Reply via email to