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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jmessa@php.net
New email:
PHP Version: OS:

 

 [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: Thu Apr 25 11:01:30 2024 UTC