#43994 [NEW]: mb_ereg 'successfully' matching incorrectly

From: Date: Thu, 31 Jan 2008 15:04:31 +0000
Subject: #43994 [NEW]: mb_ereg 'successfully' matching incorrectly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121818@lists.php.net to get a copy of this message
From: josmessa at uk dot ibm dot com Operating system: Windows XP SP2 PHP version: 5.2CVS-2008-01-31 (snap) PHP Bug Type: mbstring related Bug description: mb_ereg 'successfully' matching incorrectly Description: ------------ When mb_ereg is passed certain data types as the $pattern argument it will return int(1), i.e. a successful match, when in fact it has not matched. This is shown by setting the $regs argument and looking at the returned array which only contains one element which is bool(false). Reproduce code: --------------- <?php $unset_var = 10; unset ($unset_var); $inputs = array(NULL, null, false, FALSE, "", '', @$undefined_var, @$unset_var); $iterator = 1; foreach($inputs as $input) { if(@is_array($mb_regs)){ $mb_regs = ''; } echo "\n-- Iteration $iterator --\n"; echo "Without \$regs arg:\n"; var_dump( mb_ereg($input, 'hello, world') ); echo "With \$regs arg:\n"; var_dump(mb_ereg($input, 'hello, world', $mb_regs)); var_dump($mb_regs); $iterator++; }; ?> Expected result: ---------------- http://pastebin.com/f5f5c20ff Actual result: -------------- http://pastebin.com/f3f966bd0 -- Edit bug report at http://bugs.php.net/?id=43994&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43994&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43994&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43994&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43994&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43994&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43994&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43994&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43994&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43994&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43994&r=support Expected behavior: http://bugs.php.net/fix.php?id=43994&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43994&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43994&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43994&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43994&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43994&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43994&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43994&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43994&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43994&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43994&r=mysqlcfg

« previous php.bugs (#121818) next »