tony2001 Thu Sep 20 08:10:20 2007 UTC Added files: /php-src/ext/pcre/tests 006.phpt
Modified files: /php-src/ext/pcre php_pcre.c Log: if one of regular expressions in the array fails, return NULL right away this fixes "String is not zero-terminated" error and makes the behaviour consistent with regexps passed as strings http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/php_pcre.c?r1=1.219&r2=1.220&diff_format=u Index: php-src/ext/pcre/php_pcre.c diff -u php-src/ext/pcre/php_pcre.c:1.219 php-src/ext/pcre/php_pcre.c:1.220 --- php-src/ext/pcre/php_pcre.c:1.219 Sat Sep 1 18:01:43 2007 +++ php-src/ext/pcre/php_pcre.c Thu Sep 20 08:10:20 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pcre.c,v 1.219 2007/09/01 18:01:43 nlopess Exp $ */ +/* $Id: php_pcre.c,v 1.220 2007/09/20 08:10:20 tony2001 Exp $ */ /* TODO * php_pcre_replace_impl(): @@ -1367,8 +1367,11 @@ efree(subject_value); subject_value = result; subject_len = *result_len; + } else { + efree(subject_value); + return NULL; } - + zend_hash_move_forward(Z_ARRVAL_P(regex)); } http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/006.phpt?view=markup&rev=1.1 Index: php-src/ext/pcre/tests/006.phpt +++ php-src/ext/pcre/tests/006.phpt --TEST-- preg_replace() with array of failing regular expressions --FILE-- <?php $text = '[CODE]<td align="$stylevar[right]">[/CODE]'; $result = preg_replace(array('#\[(right)\](((?R)|[^[]+?|\[)*)\[/\\1\]#siU', '#\[(right)\](((?R)|[^[]+?|\[)*)\[/\\1\]#siU'), '', $text); var_dump($text); var_dump($result); $result = preg_replace('#\[(right)\](((?R)|[^[]+?|\[)*)\[/\\1\]#siU', '', $text); var_dump($text); var_dump($result); echo "Done\n"; ?> --EXPECTF-- string(58) "[CODE]<td align="$stylevar[right]">[/CODE]" NULL string(58) "[CODE]<td align="$stylevar[right]">[/CODE]" NULL Done --UEXPECTF-- unicode(58) "[CODE]<td align="$stylevar[right]">[/CODE]" NULL unicode(58) "[CODE]<td align="$stylevar[right]">[/CODE]" NULL Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php