|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43994 mb_ereg 'successfully' matching incorrectly
Submitted: 2008-01-31 15:04 UTC Modified: 2009-04-20 16:14 UTC
From: Assigned: hirokawa (profile)
Status: Closed Package: mbstring related
PHP Version: 5.2CVS-2008-01-31 (snap) OS: Windows XP SP2
Private report: No CVE-ID: None
 [2008-01-31 15:04 UTC]
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:
$unset_var = 10;
unset ($unset_var);
$inputs = array(NULL, null, false, FALSE, "", '', @$undefined_var, @$unset_var);

$iterator = 1;
foreach($inputs as $input) {
		$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));

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-18 14:19 UTC]
I've run the above example on the latest 5.2 and 5.3 snapshots and am getting error messages warning about empty patterns similar to that in ereg() which is great. Thanks for making the change!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 10:01:34 2024 UTC