Edit report at https://bugs.php.net/bug.php?id=62427&edit=1

 ID:                 62427
 User updated by:    danielklein at airpost dot net
 Reported by:        danielklein at airpost dot net
 Summary:            PCRE invalid "\k" sequence does not cause warning or
                     error
 Status:             Not a bug
 Type:               Bug
 Package:            PCRE related
 PHP Version:        5.4.4
 Block user comment: N
 Private report:     N

 New Comment:

I see... PHP 5.4.4 is using PCRE 8.12 (according to my phpinfo();) This 
particular bug was fixed in PCRE 8.13 :( Missed it by >that< much...
http://pcre.org/changelog.txt - Search for \k

Can PHP be updated to use the latest PCRE?

P.S. I thought you were only allowed to report issues against the current 
version of PHP? PCRE 8.02 was included in PHP 5.3.3 :p

P.P.S. The documentation is out of date on the following page:
http://www.php.net/manual/en/pcre.installation.php


Previous Comments:
------------------------------------------------------------------------
[2012-06-27 13:16:00] fel...@php.net

Not a PHP bug. The error depends on the PCRE library version.

$ pcretest 
PCRE version 8.02 2010-03-19

  re> /\k/
data> a
No match
  re> /\g/
Failed: a numbered reference must not be zero at offset 1

------------------------------------------------------------------------
[2012-06-27 03:13:13] ras...@php.net

For reference, the command pcretest tool that comes with PCRE-8.30 gives this:

  re> /\k/
Failed: \k is not followed by a braced, angle-bracketed, or quoted name at 
offset 
2
  re> /\g/
Failed: a numbered reference must not be zero at offset 1

------------------------------------------------------------------------
[2012-06-27 01:22:24] danielklein at airpost dot net

Description:
------------
The "\k" escape must be followed by 'name', <name> or {name}. A PCRE regex that 
contains "\k" without the properly quoted name will compile without an error 
and will always fail as "\k" can never (as far as I know) match anything in the 
subject string. It is almost identical to "\g", except "\g" also allows "\gn", 
"\g{n}" or "\g{-n}" where "n" is any positive decimal number.

I have been unable to test PCRE directly (i.e. via the command line, not 
through PHP) as I can't compile it on my computer. I have looked through the 
source code and the test results, and from that it seems to be working 
correctly. Although I'm not 100% sure, I think this bug is specific to PHP.

Test script:
---------------
<?php
var_dump(preg_match('/\k/', 'foo')); // Missing named reference
var_dump(preg_match('/\g/', 'foo')); // Missing named or numbered reference
?>

Expected result:
----------------
Warning: preg_match(): Compilation failed: **something about name missing in \k 
back-reference** at offset 1 in test.php on line 3
 bool(false)
Warning: preg_match(): Compilation failed: a numbered reference must not be 
zero at offset 1 in test.php on line 3
 bool(false)

Actual result:
--------------
int(0) 
Warning: preg_match(): Compilation failed: a numbered reference must not be 
zero at offset 1 in test.php on line 3
 bool(false)


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62427&edit=1

Reply via email to