php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49384 preg_match incorreclty matching vertical tab character
Submitted: 2009-08-27 09:53 UTC Modified: 2009-08-29 00:29 UTC
From: soham dot mehta at gmail dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.10 OS: x86_64 GNU/Linux
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: soham dot mehta at gmail dot com
New email:
PHP Version: OS:

 

 [2009-08-27 09:53 UTC] soham dot mehta at gmail dot com
Description:
------------
In preg_match (and preg_replace), vertical tab character matches characters other than itself. At the least, it matches ascii 10,11,12,13 and 133, when it should only match 11.

(Vertical tab has been nixed from PCRE - is that the cause?)

Reproduce code:
---------------
        $wrong = chr(133); //can use any of 10,12,13 or 133
        $x = preg_match('/\v/', $wrong, $matches, PREG_OFFSET_CAPTURE);
        var_dump($matches);

        $right = chr(11);
        $x = preg_match('/\v/', $right, $matches, PREG_OFFSET_CAPTURE);
        var_dump($matches);


Expected result:
----------------
array
  empty

array
  0 => 
    array
      0 => string '' (length=1)
      1 => int 0


Actual result:
--------------
array
  0 => 
    array
      0 => string '�' (length=1)
      1 => int 0

array
  0 => 
    array
      0 => string '' (length=1)
      1 => int 0


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-29 00:29 UTC] jani@php.net
You should use double quotes instead. Now you're not matching vertical 
tab but \v.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 13:01:30 2024 UTC