php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72693 mb_ereg_search increments search position when a match zero-width
Submitted: 2016-07-28 05:32 UTC Modified: 2016-07-28 11:59 UTC
From: ju1ius at laposte dot net Assigned: cmb (profile)
Status: Closed Package: mbstring related
PHP Version: 5.6.24 OS: Debian Sid
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ju1ius at laposte dot net
New email:
PHP Version: OS:

 

 [2016-07-28 05:32 UTC] ju1ius at laposte dot net
Description:
------------
When provided a pattern that produces a zero-width match, mb_ereg_search increments search position by one, eventhough it shouldn't.



Test script:
---------------
<?php

mb_ereg_search_init('foo');

var_dump(mb_ereg_search('\A'));
var_dump(mb_ereg_search_getpos());

var_dump(mb_ereg_search('\s*'));
var_dump(mb_ereg_search_getpos());

var_dump(mb_ereg_search('\w+'));
var_dump(mb_ereg_search_getpos());
var_dump(mb_ereg_search_getregs());

var_dump(mb_ereg_search('\s*'));
var_dump(mb_ereg_search_getpos());

var_dump(mb_ereg_search('\Z'));
var_dump(mb_ereg_search_getpos());


Expected result:
----------------
bool(true)
int(0)

bool(true)
int(0)

bool(true)
int(3)
array(1) {
  [0]=>
  string(1) "foo"
}

bool(true)
int(3)

bool(true)
int(3)

Actual result:
--------------
// warnings suppressed, see bug #72691

bool(true)
int(1)

bool(true)
int(2)

bool(true)
int(3)
array(1) {
  [0]=>
  string(1) "o"
}

bool(true)
int(4)

bool(false)
int(3)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-28 11:59 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2016-07-28 11:59 UTC] cmb@php.net
Confirmed: <https://3v4l.org/NMmr1>.
 [2016-07-28 12:27 UTC] cmb@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=56cdaecb284b2b292ce1ecb076c1f8b041e47a02
Log: Fix #72693: mb_ereg_search increments search position when a match zero-width
 [2016-07-28 12:27 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2016-10-17 10:10 UTC] bwoebi@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=56cdaecb284b2b292ce1ecb076c1f8b041e47a02
Log: Fix #72693: mb_ereg_search increments search position when a match zero-width
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 22:01:28 2024 UTC