php.net |  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: jmessa@php.net 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] jmessa@php.net
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-18 14:19 UTC] jmessa@php.net
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: Tue Mar 19 05:01:29 2024 UTC