ZF-1641: PCRE UTF-8 Support Unavailable on Some Platforms
Description
Filter and validation classes such as Zend_Filter_Alpha are known to make use of the {{/u}} PCRE pattern modifier, but UTF-8 support is not compiled by default into various PHP distributions.
Comments
Posted by Darby Felton (darby) on 2007-06-27T12:41:34.000+0000
Original comment by [~cgraefe]:
I can see why this change was made, but for me it is causing problems on certain platforms. On some, the extendes PCRE syntax "\p{}" doesn't seem to match anything. I could quite figure out what exactly is causing this problem. Up to now, I tried the following platforms:
Not working: Fedora Core 5, PHP 5.1.6, PCRE 6.3 Fedora Core 6, PHP 5.1.6, PCRE 6.6
Working: Fedora 7, PHP 5.2.2, PCRE 7.0 Solaris 10 x86, PHP 5.1.5, PCRE 6.6 Debian Etch, PHP 4.4.4, PCRE 6.7
Maybe, you could amend the docs to state the exact prerequisites to get Zend_Filter_Alnum et al. to work. That would surely help me a lot.
Posted by Darby Felton (darby) on 2007-06-27T12:45:27.000+0000
Original fw-general mailing list thread
Posted by Joshua L Ross (joshualross) on 2007-06-27T13:16:36.000+0000
I am also have this issue on
RHEL5, PHP 5.1.6, PCRE 6.6
I check redhat default build spec for PCRE 6.6 and --enable-utf8 is specified. At this point I am not 100% sure it is UTF-8 related but I do know since ZF1.0RC3 the filters Zend_Filter_Alnum and Zend_Filter_Alpha are not matching strings that should be valid.
Posted by Joshua L Ross (joshualross) on 2007-06-27T13:24:56.000+0000
These patterns continually fail regardless of the value input:
$pattern = '/[^\p{L}\p{N}' . ($this->allowWhiteSpace ? '\s' : '') . ']/u'; $pattern = '/[^\p{L}\p{N}' . ($this->allowWhiteSpace ? '\s' : '') . ']/';
So I modified the pattern to use the old alnum which works both with and without utf-8 specified. So these patterns are working:
$pattern = '/[^[:alnum:]' . ($this->allowWhiteSpace ? '\s' : '') . ']/u'; $pattern = '/[^[:alnum:]' . ($this->allowWhiteSpace ? '\s' : '') . ']/';
Posted by Darby Felton (darby) on 2007-06-27T13:39:17.000+0000
The Unicode property patterns (the ones beginning with {{\p}}) will not work if UTF-8 support is unavailable in PCRE.
From the www.pcre.org/pcre.txt" rel="nofollow">PCRE man pages:
Posted by Graham Anderson (gnanders) on 2007-06-27T17:22:31.000+0000
From testing on my platforms ( openSUSE/SUSE-OSS 10.0, 10.1, 10.2 ), I have the following results:
Up to ( but not including ) apache2-mod_php5-5.2.0-10.rpm testing against the PCRE expression in current Zend_Filter_Alnum passes.
From mod_php5 version that ships with openSUSE 10.2 ( 5.2.0-10 ) to the current available in the openSUSE build service, ( 5.2.3-29.1 ), testing against the pattern fails.
On openSUSE mod_php5-5.2.0-10 and greater is built against the system PCRE library and not the PHP bundled one, on opensuse 10.2 this is pcre-6.7-21. While patterns with UTF-8 options match against this system library outside of PHP; they do not, for whatever reason match when used inside of PHP.
Workaround, on openSUSE 10.2 an upgrade of the system PCRE to the latest available from the openSUSE build service ( pcre-7.1-16 ) will allow pattern matching inside of PHP to function as expected.
Posted by Andries Seutens (andries) on 2007-06-28T07:29:12.000+0000
Issue resolved in r5468
Posted by Darby Felton (darby) on 2007-06-28T08:30:24.000+0000
Zend_Filter_Alpha and Zend_Filter_Digits also use Unicode property matching.
Posted by Andries Seutens (andries) on 2007-06-28T08:51:43.000+0000
Sorry, I forgat about those ..... It should be fixed now. Graham Anderson or anyone else running a none UTF-8 enabled system, could you please run the unit tests for: Zend_Filter_AllTests?
I'll await your response before i close the issue.
Posted by Andries Seutens (andries) on 2007-06-28T09:30:34.000+0000
Thanks to Julian Davchev for testing this:
Here stuff on local machine:
svn update U tests/Zend/Filter/AlphaTest.php U library/Zend/Filter/Alnum.php U library/Zend/Filter/Digits.php U library/Zend/Filter/Alpha.php Updated to revision 5469. At revision 5469.
jmut@dexter:/storage/www/frameworks/zendframework$ php tests/Zend/Filter/AllTests.php PHPUnit 3.0.0 by Sebastian Bergmann.
......................................... ......................................... ...........................
Time: 00:00
OK (109 tests)