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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 10:01:29 2025 UTC