From: danielklein at airpost dot net
Operating system:
PHP version: 5.4.4
Package: PCRE related
Bug Type: Bug
Bug description:PCRE invalid "\k" sequence does not cause warning or error
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 bug report at https://bugs.php.net/bug.php?id=62427&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62427&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62427&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=62427&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62427&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=62427&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62427&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=62427&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=62427&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=62427&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=62427&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=62427&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=62427&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=62427&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62427&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=62427&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62427&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=62427&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=62427&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=62427&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=62427&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=62427&r=mysqlcfg