ID:               44928
 User updated by:  php dot net at waisse dot org
-Summary:          classes no more work with PHP 5.2.6 preg_* functions,
                   but pcre support classes
 Reported By:      php dot net at waisse dot org
 Status:           Bogus
 Bug Type:         PCRE related
 Operating System: gentoo linux
 PHP Version:      5.2.6
 New Comment:

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 )


Previous Comments:
------------------------------------------------------------------------

[2008-05-07 00:00:02] [EMAIL PROTECTED]

This is a PCRE library issue, not the PHP extension.
Probably related to item 23 in http://pcre.org/changelog.txt

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

[2008-05-06 14:28:51] 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



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


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

Reply via email to