[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/standard/string.c branches/PHP_5_3/ext/standard/tests/strings/bug54454.phpt branches/PHP_5_3/ext/standard/tests/strings/substr_c

2011-04-03 Thread Pierrick Charron
pierrick Sun, 03 Apr 2011 07:18:27 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=309910

Log:
Fixed bug #54454 (substr_compare incorrectly reports equality in some cases)

Bug: http://bugs.php.net/54454 (Open) substr_compare incorrectly reports 
equality in some cases
  
Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
U   php/php-src/branches/PHP_5_3/ext/standard/string.c
A   php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug54454.phpt
U   
php/php-src/branches/PHP_5_3/ext/standard/tests/strings/substr_compare.phpt
U   php/php-src/trunk/ext/standard/string.c
A   php/php-src/trunk/ext/standard/tests/strings/bug54454.phpt
U   php/php-src/trunk/ext/standard/tests/strings/substr_compare.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS   2011-04-03 02:59:13 UTC (rev 309909)
+++ php/php-src/branches/PHP_5_3/NEWS   2011-04-03 07:18:27 UTC (rev 309910)
@@ -9,10 +9,13 @@

 - Core:
   . Fixed a crash inside dtor for error handling. (Ilia)
+  . Fixed bug #54454 (substr_compare incorrectly reports equality in some
+cases). (Pierrick)
   . Fixed bug #54180 (parse_url() incorrectly parses path when ? in fragment).
 (tomas dot brastavicius at quantum dot lt, Pierrick)
-   . Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using
- TMPDIR on Windows). (Pierre)
+  . Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using
+TMPDIR on Windows). (Pierre)
+
 - cURL
   . Added CURLINFO_REDIRECT_URL support. (Daniel Stenberg, Pierre)


Modified: php/php-src/branches/PHP_5_3/ext/standard/string.c
===
--- php/php-src/branches/PHP_5_3/ext/standard/string.c  2011-04-03 02:59:13 UTC 
(rev 309909)
+++ php/php-src/branches/PHP_5_3/ext/standard/string.c  2011-04-03 07:18:27 UTC 
(rev 309910)
@@ -5243,10 +5243,6 @@
RETURN_FALSE;
}

-   if (len  s1_len - offset) {
-   len = s1_len - offset;
-   }
-
cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset)));

if (!cs) {

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug54454.phpt
===
--- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug54454.phpt   
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug54454.phpt   
2011-04-03 07:18:27 UTC (rev 309910)
@@ -0,0 +1,8 @@
+--TEST--
+Bug #54454 (substr_compare incorrectly reports equality in some cases)
+--FILE--
+?php
+var_dump(substr_compare('/', '/asd', 0, 4));
+?
+--EXPECT--
+int(-3)

Modified: 
php/php-src/branches/PHP_5_3/ext/standard/tests/strings/substr_compare.phpt
===
--- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/substr_compare.phpt 
2011-04-03 02:59:13 UTC (rev 309909)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/substr_compare.phpt 
2011-04-03 07:18:27 UTC (rev 309910)
@@ -27,7 +27,7 @@

 Warning: substr_compare(): The start position cannot exceed initial string 
length in %s on line %d
 bool(false)
-int(0)
+int(-1)

 Warning: substr_compare() expects parameter 5 to be boolean, object given in 
%s on line %d
 bool(false)

Modified: php/php-src/trunk/ext/standard/string.c
===
--- php/php-src/trunk/ext/standard/string.c 2011-04-03 02:59:13 UTC (rev 
309909)
+++ php/php-src/trunk/ext/standard/string.c 2011-04-03 07:18:27 UTC (rev 
309910)
@@ -5252,10 +5252,6 @@
RETURN_FALSE;
}

-   if (len  s1_len - offset) {
-   len = s1_len - offset;
-   }
-
cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset)));

if (!cs) {

Added: php/php-src/trunk/ext/standard/tests/strings/bug54454.phpt
===
--- php/php-src/trunk/ext/standard/tests/strings/bug54454.phpt  
(rev 0)
+++ php/php-src/trunk/ext/standard/tests/strings/bug54454.phpt  2011-04-03 
07:18:27 UTC (rev 309910)
@@ -0,0 +1,8 @@
+--TEST--
+Bug #54454 (substr_compare incorrectly reports equality in some cases)
+--FILE--
+?php
+var_dump(substr_compare('/', '/asd', 0, 4));
+?
+--EXPECT--
+int(-3)

Modified: php/php-src/trunk/ext/standard/tests/strings/substr_compare.phpt
===
--- php/php-src/trunk/ext/standard/tests/strings/substr_compare.phpt
2011-04-03 02:59:13 UTC (rev 309909)
+++ php/php-src/trunk/ext/standard/tests/strings/substr_compare.phpt
2011-04-03 07:18:27 UTC (rev 309910)
@@ -27,7 +27,7 @@

 Warning: substr_compare(): The start position cannot exceed initial string 
length in %s on line %d
 

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/filter/sanitizing_filters.c branches/PHP_5_3/ext/filter/tests/bug53037.phpt trunk/ext/filter/sanitizing_filters.c trunk/ext/filt

2011-04-03 Thread Ilia Alshanetsky
iliaaSun, 03 Apr 2011 16:30:31 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=309920

Log:
Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented).

Bug: http://bugs.php.net/53037 (Open) activate FILTER_FLAG_EMPTY_STRING_NULL
  
Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
U   php/php-src/branches/PHP_5_3/ext/filter/sanitizing_filters.c
A   php/php-src/branches/PHP_5_3/ext/filter/tests/bug53037.phpt
U   php/php-src/trunk/ext/filter/sanitizing_filters.c
A   php/php-src/trunk/ext/filter/tests/bug53037.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS   2011-04-03 12:25:43 UTC (rev 309919)
+++ php/php-src/branches/PHP_5_3/NEWS   2011-04-03 16:30:31 UTC (rev 309920)
@@ -28,6 +28,9 @@
 - DBA extension:
   . Fixed bug #54242 (dba_insert returns true if key already exists). (Felipe)

+- Filter extension:
+  . Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented). (Ilia)
+
 - LDAP extension:
   . Fixed bug #53339 (Fails to build when compilng with gcc 4.5 and DSO
 libraries). (Clint Byrum, Raphael)

Modified: php/php-src/branches/PHP_5_3/ext/filter/sanitizing_filters.c
===
--- php/php-src/branches/PHP_5_3/ext/filter/sanitizing_filters.c
2011-04-03 12:25:43 UTC (rev 309919)
+++ php/php-src/branches/PHP_5_3/ext/filter/sanitizing_filters.c
2011-04-03 16:30:31 UTC (rev 309920)
@@ -205,7 +205,11 @@

if (new_len == 0) {
zval_dtor(value);
-   ZVAL_EMPTY_STRING(value);
+   if (flags  FILTER_FLAG_EMPTY_STRING_NULL) {
+   ZVAL_NULL(value);
+   } else {
+   ZVAL_EMPTY_STRING(value);
+   }
return;
}
 }
@@ -280,6 +284,9 @@
}

php_filter_encode_html(value, enc);
+   } else if (flags  FILTER_FLAG_EMPTY_STRING_NULL  Z_STRLEN_P(value) 
== 0) {
+   zval_dtor(value);
+   ZVAL_NULL(value);
}
 }
 /* }}} */

Added: php/php-src/branches/PHP_5_3/ext/filter/tests/bug53037.phpt
===
--- php/php-src/branches/PHP_5_3/ext/filter/tests/bug53037.phpt 
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/filter/tests/bug53037.phpt 2011-04-03 
16:30:31 UTC (rev 309920)
@@ -0,0 +1,14 @@
+--TEST--
+Bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented)
+--SKIPIF--
+?php if (!extension_loaded(filter)) die(skip); ?
+--FILE--
+?php
+var_dump(
+   filter_var(, FILTER_DEFAULT),
+filter_var(, FILTER_DEFAULT, array('flags' = 
FILTER_FLAG_EMPTY_STRING_NULL))
+);
+?
+--EXPECT--
+string(0) 
+NULL

Modified: php/php-src/trunk/ext/filter/sanitizing_filters.c
===
--- php/php-src/trunk/ext/filter/sanitizing_filters.c   2011-04-03 12:25:43 UTC 
(rev 309919)
+++ php/php-src/trunk/ext/filter/sanitizing_filters.c   2011-04-03 16:30:31 UTC 
(rev 309920)
@@ -205,7 +205,11 @@

if (new_len == 0) {
zval_dtor(value);
-   ZVAL_EMPTY_STRING(value);
+   if (flags  FILTER_FLAG_EMPTY_STRING_NULL) {
+   ZVAL_NULL(value);
+   } else {
+   ZVAL_EMPTY_STRING(value);
+   }
return;
}
 }
@@ -280,6 +284,9 @@
}

php_filter_encode_html(value, enc);
+   } else if (flags  FILTER_FLAG_EMPTY_STRING_NULL  Z_STRLEN_P(value) 
== 0) {
+   zval_dtor(value);
+   ZVAL_NULL(value);
}
 }
 /* }}} */

Added: php/php-src/trunk/ext/filter/tests/bug53037.phpt
===
--- php/php-src/trunk/ext/filter/tests/bug53037.phpt
(rev 0)
+++ php/php-src/trunk/ext/filter/tests/bug53037.phpt2011-04-03 16:30:31 UTC 
(rev 309920)
@@ -0,0 +1,14 @@
+--TEST--
+Bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented)
+--SKIPIF--
+?php if (!extension_loaded(filter)) die(skip); ?
+--FILE--
+?php
+var_dump(
+   filter_var(, FILTER_DEFAULT),
+filter_var(, FILTER_DEFAULT, array('flags' = 
FILTER_FLAG_EMPTY_STRING_NULL))
+);
+?
+--EXPECT--
+string(0) 
+NULL

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

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/INSTALL branches/PHP_5_3/ext/imap/php_imap.c branches/PHP_5_3/ext/pcntl/tests/pcntl_fork_basic.phpt branches/PHP_5_3/ext/snmp/snmp.c branches/PHP_5_3/ext/

2011-04-03 Thread Pierrick Charron
pierrick Sun, 03 Apr 2011 21:46:52 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=309927

Log:
Fix common typos in the source code (Reported in Bug #54065)
# External libraries were excluded
# Thanks eitan at eitanadler dot com for the first patch :)

Bug: http://bugs.php.net/54065 (Open) fix common typos in documentation
  
Changed paths:
U   php/php-src/branches/PHP_5_3/INSTALL
U   php/php-src/branches/PHP_5_3/ext/imap/php_imap.c
U   php/php-src/branches/PHP_5_3/ext/pcntl/tests/pcntl_fork_basic.phpt
U   php/php-src/branches/PHP_5_3/ext/snmp/snmp.c
U   php/php-src/branches/PHP_5_3/ext/spl/internal/appenditerator.inc
U   php/php-src/branches/PHP_5_3/ext/spl/internal/cachingiterator.inc
U   php/php-src/branches/PHP_5_3/ext/spl/internal/regexiterator.inc
U   php/php-src/branches/PHP_5_3/ext/standard/array.c
U   
php/php-src/branches/PHP_5_3/ext/standard/tests/array/array_shift_variation5.phpt
U   
php/php-src/branches/PHP_5_3/ext/standard/tests/file/lstat_stat_variation9.phpt
U   php/php-src/branches/PHP_5_3/ext/xmlreader/php_xmlreader.c
U   php/php-src/branches/PHP_5_3/main/streams/php_stream_context.h
U   php/php-src/branches/PHP_5_3/main/streams/php_stream_filter_api.h
U   php/php-src/branches/PHP_5_3/sapi/litespeed/README
U   
php/php-src/branches/PHP_5_3/scripts/dev/generate-phpt/src/gtTestSubject.php
U   
php/php-src/branches/PHP_5_3/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php
U   
php/php-src/branches/PHP_5_3/scripts/dev/generate-phpt/src/testcase/gtTestCase.php
U   php/php-src/branches/PHP_5_3/win32/install.txt
U   php/php-src/trunk/INSTALL
U   php/php-src/trunk/ext/imap/php_imap.c
U   php/php-src/trunk/ext/pcntl/tests/pcntl_fork_basic.phpt
U   php/php-src/trunk/ext/spl/internal/appenditerator.inc
U   php/php-src/trunk/ext/spl/internal/cachingiterator.inc
U   php/php-src/trunk/ext/spl/internal/regexiterator.inc
U   php/php-src/trunk/ext/standard/array.c
U   php/php-src/trunk/ext/standard/tests/array/array_shift_variation5.phpt
U   php/php-src/trunk/ext/standard/tests/file/lstat_stat_variation9.phpt
U   php/php-src/trunk/ext/xmlreader/php_xmlreader.c
U   php/php-src/trunk/main/streams/php_stream_context.h
U   php/php-src/trunk/main/streams/php_stream_filter_api.h
U   php/php-src/trunk/php.ini-development
U   php/php-src/trunk/php.ini-production
U   php/php-src/trunk/sapi/litespeed/README
U   php/php-src/trunk/scripts/dev/generate-phpt/src/gtTestSubject.php
U   
php/php-src/trunk/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php
U   php/php-src/trunk/scripts/dev/generate-phpt/src/testcase/gtTestCase.php
U   php/php-src/trunk/win32/install.txt

Modified: php/php-src/branches/PHP_5_3/INSTALL
===
--- php/php-src/branches/PHP_5_3/INSTALL	2011-04-03 21:07:48 UTC (rev 309926)
+++ php/php-src/branches/PHP_5_3/INSTALL	2011-04-03 21:46:52 UTC (rev 309927)
@@ -1535,7 +1535,7 @@
core directives is available in the appendix. Probably not all PHP
directives are documented in the manual though. For a complete list of
directives available in your PHP version, please read your well
-   commented php.ini file. Alternatively, you may find the the latest
+   commented php.ini file. Alternatively, you may find the latest
php.ini from SVN helpful too.

Example 6-1. php.ini example

Modified: php/php-src/branches/PHP_5_3/ext/imap/php_imap.c
===
--- php/php-src/branches/PHP_5_3/ext/imap/php_imap.c	2011-04-03 21:07:48 UTC (rev 309926)
+++ php/php-src/branches/PHP_5_3/ext/imap/php_imap.c	2011-04-03 21:46:52 UTC (rev 309927)
@@ -4299,7 +4299,7 @@
 			charset_token = offset;
 		}
 		/* Return the rest of the data as unencoded, as it was either unencoded or was missing separators
-		   which rendered the the remainder of the string impossible for us to decode. */
+		   which rendered the remainder of the string impossible for us to decode. */
 		memcpy(text, string[charset_token], end - charset_token);	/* Extract unencoded text from string */
 		text[end - charset_token] = 0x00;
 		MAKE_STD_ZVAL(myobject);

Modified: php/php-src/branches/PHP_5_3/ext/pcntl/tests/pcntl_fork_basic.phpt
===
--- php/php-src/branches/PHP_5_3/ext/pcntl/tests/pcntl_fork_basic.phpt	2011-04-03 21:07:48 UTC (rev 309926)
+++ php/php-src/branches/PHP_5_3/ext/pcntl/tests/pcntl_fork_basic.phpt	2011-04-03 21:46:52 UTC (rev 309927)
@@ -11,7 +11,7 @@
 ?
 --FILE--
 ?php
-echo *** Test by calling method or function with its expected arguments, first print the child PID and the the father ***\n;
+echo *** Test by calling method or function with its expected arguments, first print the child PID and the father ***\n;

[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/ NEWS ext/spl/spl_directory.c ext/spl/spl_iterators.c ext/spl/tests/bug54384.phpt ext/spl/tests/iterator_031.phpt

2011-04-03 Thread Gustavo André dos Santos Lopes
cataphract   Mon, 04 Apr 2011 02:50:27 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=309929

Log:
- Fixed bug #54384 (Dual iterators, GlobIterator, SplFileObject and
  SplTempFileObject crash when user-space classes don't call the paren
  constructor).

Bug: http://bugs.php.net/54384 (Assigned) Several SPL classes crash when parent 
constructor is not called
  
Changed paths:
U   php/php-src/branches/PHP_5_3/NEWS
U   php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c
U   php/php-src/branches/PHP_5_3/ext/spl/spl_iterators.c
A   php/php-src/branches/PHP_5_3/ext/spl/tests/bug54384.phpt
U   php/php-src/branches/PHP_5_3/ext/spl/tests/iterator_031.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS	2011-04-04 02:49:47 UTC (rev 309928)
+++ php/php-src/branches/PHP_5_3/NEWS	2011-04-04 02:50:27 UTC (rev 309929)
@@ -68,6 +68,9 @@
   . Fixed bug #51958 (socket_accept() fails on IPv6 server sockets). (Gustavo)

 - SPL extension:
+  . Fixed bug #54384 (Dual iterators, GlobIterator, SplFileObject and
+SplTempFileObject crash when user-space classes don't call the paren
+constructor). (Gustavo)
   . Fixed bug #54292 (Wrong parameter causes crash in
 SplFileObject::__construct()). (Felipe)
   . Fixed bug #54291 (Crash iterating DirectoryIterator for dir name starting

Modified: php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c
===
--- php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c	2011-04-04 02:49:47 UTC (rev 309928)
+++ php/php-src/branches/PHP_5_3/ext/spl/spl_directory.c	2011-04-04 02:50:27 UTC (rev 309929)
@@ -48,6 +48,8 @@

 /* declare the class handlers */
 static zend_object_handlers spl_filesystem_object_handlers;
+/* includes handler to validate object state when retrieving methods */
+static zend_object_handlers spl_filesystem_object_check_handlers;

 /* decalre the class entry */
 PHPAPI zend_class_entry *spl_ce_SplFileInfo;
@@ -162,6 +164,16 @@
 }
 /* }}} */

+/* {{{ spl_filesystem_object_new_ex */
+static zend_object_value spl_filesystem_object_new_check(zend_class_entry *class_type TSRMLS_DC)
+{
+	zend_object_value ret = spl_filesystem_object_new_ex(class_type, NULL TSRMLS_CC);
+	ret.handlers = spl_filesystem_object_check_handlers;
+	return ret;
+}
+/* }}} */
+
+
 PHPAPI char* spl_filesystem_object_get_path(spl_filesystem_object *intern, int *len TSRMLS_DC) /* {{{ */
 {
 #ifdef HAVE_GLOB
@@ -617,6 +629,19 @@
 }
 /* }}} */

+zend_function *spl_filesystem_object_get_method_check(zval **object_ptr, char *method, int method_len TSRMLS_DC) /* {{{ */
+{
+	spl_filesystem_object *fsobj = zend_object_store_get_object(*object_ptr TSRMLS_CC);
+
+	if (fsobj-u.dir.entry.d_name[0] == '\0'  fsobj-orig_path == NULL) {
+		method = _bad_state_ex;
+		method_len = sizeof(_bad_state_ex) - 1;
+	}
+
+	return zend_get_std_object_handlers()-get_method(object_ptr, method, method_len TSRMLS_CC);
+}
+/* }}} */
+
 #define DIT_CTOR_FLAGS  0x0001
 #define DIT_CTOR_GLOB   0x0002

@@ -1354,6 +1379,15 @@
 }
 /* }}} */

+/* {{{ */
+SPL_METHOD(SplFileInfo, _bad_state_ex)
+{
+	zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC,
+		The parent constructor was not called: the object is in an 
+		invalid state );
+}
+/* }}} */
+
 /* {{{ proto void FilesystemIterator::__construct(string path [, int flags])
  Cronstructs a new dir iterator from a path. */
 SPL_METHOD(FilesystemIterator, __construct)
@@ -1891,6 +1925,7 @@
 	SPL_ME(SplFileInfo,   openFile,  arginfo_info_openFile, ZEND_ACC_PUBLIC)
 	SPL_ME(SplFileInfo,   setFileClass,  arginfo_info_optinalFileClass, ZEND_ACC_PUBLIC)
 	SPL_ME(SplFileInfo,   setInfoClass,  arginfo_info_optinalFileClass, ZEND_ACC_PUBLIC)
+	SPL_ME(SplFileInfo,   _bad_state_ex, NULL,			ZEND_ACC_PUBLIC)
 	SPL_MA(SplFileInfo,   __toString, SplFileInfo, getPathname, arginfo_splfileinfo_void, ZEND_ACC_PUBLIC)
 	{NULL, NULL, NULL}
 };
@@ -2922,13 +2957,16 @@

 	REGISTER_SPL_SUB_CLASS_EX(RecursiveDirectoryIterator, FilesystemIterator, spl_filesystem_object_new, spl_RecursiveDirectoryIterator_functions);
 	REGISTER_SPL_IMPLEMENTS(RecursiveDirectoryIterator, RecursiveIterator);
+
+	memcpy(spl_filesystem_object_check_handlers, spl_filesystem_object_handlers, sizeof(zend_object_handlers));
+	spl_filesystem_object_check_handlers.get_method = spl_filesystem_object_get_method_check;

 #ifdef HAVE_GLOB
-	REGISTER_SPL_SUB_CLASS_EX(GlobIterator, FilesystemIterator, spl_filesystem_object_new, spl_GlobIterator_functions);
+	REGISTER_SPL_SUB_CLASS_EX(GlobIterator, FilesystemIterator, spl_filesystem_object_new_check, spl_GlobIterator_functions);
 	REGISTER_SPL_IMPLEMENTS(GlobIterator, Countable);
 #endif

-	REGISTER_SPL_SUB_CLASS_EX(SplFileObject, SplFileInfo, spl_filesystem_object_new, spl_SplFileObject_functions);
+