Re: cvs: php4 /ext/mbstring php_mbregex.c

From: Date: Sun, 06 Oct 2002 08:54:34 +0000
Subject: Re: cvs: php4 /ext/mbstring php_mbregex.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-14597@lists.php.net to get a copy of this message
On Sun, 6 Oct 2002, Moriyoshi Koizumi wrote: > moriyoshi Sun Oct 6 02:21:34 2002 EDT > > Modified files: > /php4/ext/mbstring php_mbregex.c > Log: > Warnings for empty regular expressions Please merge this to the brach too! Derick > > > Index: php4/ext/mbstring/php_mbregex.c > diff -u php4/ext/mbstring/php_mbregex.c:1.5 php4/ext/mbstring/php_mbregex.c:1.6 > --- php4/ext/mbstring/php_mbregex.c:1.5 Tue Aug 27 11:32:04 2002 > +++ php4/ext/mbstring/php_mbregex.c Sun Oct 6 02:21:34 2002 > @@ -16,7 +16,7 @@ > +----------------------------------------------------------------------+ > */ > > -/* $Id: php_mbregex.c,v 1.5 2002/08/27 15:32:04 helly Exp $ */ > +/* $Id: php_mbregex.c,v 1.6 2002/10/06 06:21:34 moriyoshi Exp $ */ > > > #ifdef HAVE_CONFIG_H > @@ -307,7 +307,9 @@ > mbre_free_registers(&regs); > RETURN_FALSE; > } > - > + if (regs.beg[0] == regs.end[0]) { > + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty regular expression"); > + } > match_len = 1; > str = Z_STRVAL_PP(arg_string); > if (array) { > @@ -423,6 +425,10 @@ > pos = 0; > while (err >= 0) { > err = mbre_search(&re, string, string_len, pos, string_len - pos, &regs); > + if ( regs.beg[0] == regs.end[0] ) { > + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty regular expression"); > + break; > + } > if (err <= -2) { > php_error_docref(NULL TSRMLS_CC, E_WARNING, "mbregex search failure in > php_mbereg_replace_exec()"); > break; > @@ -565,20 +571,19 @@ > /* churn through str, generating array entries as we go */ > while ((count != 0) && > (err = mbre_search(&re, string, string_len, pos, string_len - pos, &regs)) >= > 0) { > + if ( regs.beg[0] == regs.end[0] ) { > + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty regular expression"); > + break; > + } > + > n = regs.beg[0]; > - if (n == pos) { > - /* match is at start of string, return empty string */ > - add_next_index_stringl(return_value, empty_string, 0, 1); > + /* add it to the array */ > + if (n < string_len && n <= pos) { > + n -= pos; > + add_next_index_stringl(return_value, &string[pos], n, 1); > } else { > - /* On a real match */ > - /* add it to the array */ > - if (n < string_len) { > - n -= pos; > - add_next_index_stringl(return_value, &string[pos], n, 1); > - } else { > - err = -2; > - break; > - } > + err = -2; > + break; > } > /* point at our new starting point */ > n = regs.end[0]; > @@ -736,7 +741,6 @@ > } > > err = mbre_search(MBSTRG(search_re), str, len, pos, len - pos, MBSTRG(search_regs)); > - > if (err <= -2) { > php_error_docref(NULL TSRMLS_CC, E_WARNING, "mbregex search failure in > mbregex_search()"); > RETVAL_FALSE; > @@ -744,6 +748,9 @@ > MBSTRG(search_pos) = len; > RETVAL_FALSE; > } else { > + if (MBSTRG(search_regs)->beg[0] == MBSTRG(search_regs)->end[0]) { > + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty regular expression"); > + } > switch (mode) { > case 1: > if (array_init(return_value) != FAILURE) { > > > > -- > PHP CVS Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- --------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ JDI Media Solutions --------------[ if you hold a unix shell to your ear, do you hear the c? ]-

« previous php.cvs (#14597) next »