|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-05-06 14:28 UTC] php dot net at waisse dot org
Description:
------------
Using classes in preg_* functions worked before 5.2.6
After upgrading to 5.2.6 classes like [:space:] no more work
I had to replace all [:class:] with things like \s
Reproduce code:
---------------
the regular expression :
list($header) = preg_split(',<(item|entry)[:[:space:]>],', $rss, 2);
worked before PHP 5.2.6
no more working now, I had to change this to :
list($header) = preg_split(',<(item|entry)[:\s>],', $rss, 2);
and it works again.
Expected result:
----------------
see http://www.pcre.org/pcre.txt
it says that pcre supports classes
( POSIX CHARACTER CLASSES
Perl supports the POSIX notation for character classes. This uses names enclosed by [: and :] within the enclosing square brackets. PCRE also supports this notation. )
so the classes should work with PHP 5.2.6 pcre ( preg_* fucntions )
this always worked before and thousands of websites are using them.
The above code is sandard spip ( http://spip.net ) code for years and this feature change in PHP 5.2.6 makes that all spip websites no more work with PHP 5.2.6.
Probably many other CMS will have the same problem.
Could anyone confirm that this is a PHP 5.2.6 pcre implementation bug before we try to insert a workaround in spip code ?
The regular expression seems ok since this works after replacing [:space:] with \s .
Actual result:
--------------
Warning: preg_split() [function.preg-split]: Compilation failed: POSIX named classes are supported only within a class at offset 13 in /www/spanish.feeder.ww7.be/html/ecrire/inc/syndic.php on line 145
Warning: preg_match_all() [function.preg-match-all]: Compilation failed: POSIX named classes are supported only within a class at offset 14 in /www/spanish.feeder.ww7.be/html/ecrire/inc/syndic.php on
line 166
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
I finally found the answer to this problem ( thanks to #php on frenode ), this is not a PHP bug indeed , but PCRE change the way they interpret classes. replacing : list($header) = preg_split(',<(item|entry)[:[:space:]>],', $rss, 2); with : preg_split(',<(item|entry)[\:[:space:]>],', $rss, 2); makes it work again ( if i understood correctly the first [: was interpreted as class and the second [: had problems, escaping the first : makes it OK ) ( beware all, this was working without escaping before this new PCRE version, so many websites will have to be modified )