php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44928 workaround for new PCRE behaviour
Submitted: 2008-05-06 14:28 UTC Modified: 2008-05-08 11:49 UTC
Votes:10
Avg. Score:4.8 ± 0.6
Reproduced:5 of 6 (83.3%)
Same Version:5 (100.0%)
Same OS:4 (80.0%)
From: php dot net at waisse dot org Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.6 OS: gentoo 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: php dot net at waisse dot org
New email:
PHP Version: OS:

 

 [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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-07 00:00 UTC] felipe@php.net
This is a PCRE library issue, not the PHP extension.
Probably related to item 23 in http://pcre.org/changelog.txt
 [2008-05-08 11:49 UTC] php dot net at waisse dot org
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 )
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 23:01:30 2024 UTC