johannes                                 Mon, 25 Jan 2010 23:41:18 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=294034

Log:
merge r292823 Fixed bug #44827 (define() allows :: in constant names). (iliaa)
and r293974 Added test case for bug #44827 (iliaa)

Bug: http://bugs.php.net/44827 (Closed) define('::') can be defined
      
Changed paths:
    _U  php/php-src/branches/PHP_5_3_2/
    U   php/php-src/branches/PHP_5_3_2/NEWS
    A + php/php-src/branches/PHP_5_3_2/Zend/tests/bug44827.phpt
        (from php/php-src/branches/PHP_5_3/Zend/tests/bug44827.phpt:r293974)
    U   php/php-src/branches/PHP_5_3_2/Zend/zend_builtin_functions.c


Property changes on: php/php-src/branches/PHP_5_3_2
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/php/php-src/branches/PHP_5_3:292504,292574,292594-292595,292611,292624,292630,292632-292635,292654,292677,292682-292683,292693,292719,292762,292765,292771,292777
/php/php-src/trunk:284726
   + 
/php/php-src/branches/PHP_5_3:292504,292574,292594-292595,292611,292624,292630,292632-292635,292654,292677,292682-292683,292693,292719,292762,292765,292771,292777,292823,293974
/php/php-src/trunk:284726

Modified: php/php-src/branches/PHP_5_3_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3_2/NEWS 2010-01-25 23:36:07 UTC (rev 294033)
+++ php/php-src/branches/PHP_5_3_2/NEWS 2010-01-25 23:41:18 UTC (rev 294034)
@@ -11,6 +11,7 @@
   in HTTP uploads). (Ilia)
 - Fixed bug #47409 (extract() problem with array containing word "this").
   (Ilia, chrisstocktonaz at gmail dot com)
+- Fixed bug #44827 (define() allows :: in constant names). (Ilia)


 22 Dec 2009, PHP 5.3.2 RC 1

Copied: php/php-src/branches/PHP_5_3_2/Zend/tests/bug44827.phpt (from rev 
293974, php/php-src/branches/PHP_5_3/Zend/tests/bug44827.phpt)
===================================================================
--- php/php-src/branches/PHP_5_3_2/Zend/tests/bug44827.phpt                     
        (rev 0)
+++ php/php-src/branches/PHP_5_3_2/Zend/tests/bug44827.phpt     2010-01-25 
23:41:18 UTC (rev 294034)
@@ -0,0 +1,11 @@
+--TEST--
+Bug #44827 (define() allows :: in constant names)
+--FILE--
+<?php
+define('foo::bar', 1);
+define('::', 1);
+?>
+--EXPECTF--
+Warning: Class constants cannot be defined or redefined in %sbug44827.php on 
line %d
+
+Warning: Class constants cannot be defined or redefined in %sbug44827.php on 
line %d

Modified: php/php-src/branches/PHP_5_3_2/Zend/zend_builtin_functions.c
===================================================================
--- php/php-src/branches/PHP_5_3_2/Zend/zend_builtin_functions.c        
2010-01-25 23:36:07 UTC (rev 294033)
+++ php/php-src/branches/PHP_5_3_2/Zend/zend_builtin_functions.c        
2010-01-25 23:41:18 UTC (rev 294034)
@@ -629,7 +629,6 @@
        zend_bool non_cs = 0;
        int case_sensitive = CONST_CS;
        zend_constant c;
-       char *p;

        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|b", &name, 
&name_len, &val, &non_cs) == FAILURE) {
                return;
@@ -640,31 +639,9 @@
        }

        /* class constant, check if there is name and make sure class is valid 
& exists */
-       if ((p = zend_memnstr(name, "::", sizeof("::") - 1, name + name_len))) {
-               char *class_name;
-               int found;
-               zend_class_entry **ce;
-               ALLOCA_FLAG(use_heap)
-
-               if (p == (name + name_len - sizeof("::") + 1)) {
-                       zend_error(E_WARNING, "Class constant must have a 
name");
-                       RETURN_FALSE;
-               } else if (p == name) {
-                       zend_error(E_WARNING, "Missing class name");
-                       RETURN_FALSE;
-               }
-
-               class_name = do_alloca((p - name + 1), use_heap);
-               zend_str_tolower_copy(class_name, name, (p - name));
-
-               found = zend_hash_find(EG(class_table), class_name, p - name + 
1, (void **) &ce);
-
-               if (found != SUCCESS) {
-                       zend_error(E_WARNING, "Class '%s' does not exist", 
class_name);
-                       free_alloca(class_name, use_heap);
-                       RETURN_FALSE;
-               }
-               free_alloca(class_name, use_heap);
+       if (zend_memnstr(name, "::", sizeof("::") - 1, name + name_len)) {
+               zend_error(E_WARNING, "Class constants cannot be defined or 
redefined");
+               RETURN_FALSE;
        }

 repeat:

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

Reply via email to