php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47598 FILTER_VALIDATE_EMAIL is locale aware
Submitted: 2009-03-08 13:22 UTC Modified: 2009-03-08 18:25 UTC
From: mikael at bluemist dot se Assigned: iliaa (profile)
Status: Closed Package: Filter related
PHP Version: 5.2.9 OS: Gentoo & Slackware
Private report: No CVE-ID: None
 [2009-03-08 13:22 UTC] mikael at bluemist dot se
Description:
------------
FILTER_VALIDATE_EMAIL is locale aware and produces different results depending on the locale set. Or more specific the \w escape sequence used in the regular expression is locale aware.

From http://www.php.net/manual/en/regexp.reference.php:
"The definition of letters and digits is controlled by PCRE's character tables, and may vary if locale-specific matching is taking place. For example, in the "fr" (French) locale, some character codes greater than 128 are used for accented letters, and these are matched by \w."

Reproduce code:
---------------
setlocale(LC_CTYPE, 'C');
var_dump(filter_var('???@example.com', FILTER_VALIDATE_EMAIL));
setlocale(LC_CTYPE, 'sv_SE');
var_dump(filter_var('???@example.com', FILTER_VALIDATE_EMAIL));

Expected result:
----------------
bool(false)
string(15) "???@example.com"

Actual result:
--------------
string(15) "???@example.com"
string(15) "???@example.com"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-08 13:25 UTC] mikael at bluemist dot se
Sorry, expected result = actual result and actual = expected.
 [2009-03-08 13:55 UTC] mikael at bluemist dot se
After reading the RFC I realized characters like ? ? ? (hex e5 e4 f6) are not allowed (at least not unquoted). So the expected result should be:
bool(false)
bool(false)
 [2009-03-08 18:25 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC