|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60381 FILTER_VALIDATE_EMAIL invalid punycode regexp
Submitted: 2011-11-25 08:40 UTC Modified: 2011-11-29 08:24 UTC
From: enderstd at gmail dot com Assigned:
Status: Closed Package: Filter related
PHP Version: 5.3.8 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
37 + 32 = ?
Subscribe to this entry?

 [2011-11-25 08:40 UTC] enderstd at gmail dot com
IDN domains can contain hyphens in its name.

When we convert these domain names to punycode we end up with several hyphens in 
a row.
For example: xn----7sbbtkohtqhvkc8j.xn--p1ai (культура-пенза.рф)
Yet it is a valid domain name.

The regexp in the ext/filter/logical_filters.c:525 doens't allow multiple 
hyphens but two:

> ... (?:(?:(?:xn--)?[a-z0-9]+( ....

So if I try filter_var("asd@xn----7sbbtkohtqhvkc8j.xn--p1ai", 
FILTER_VALIDATE_EMAIL) it returns false.

I think valid regexp will be like (?:xn-(-)+)?[a-z0-9]+ yet I can't be sure 
since this regexp is 
really scary.

Test script:

var_dump(filter_var("asd@xn----7sbbtkohtqhvkc8j.xn--p1ai", FILTER_VALIDATE_EMAIL));

Expected result:
string(35) "asd@xn----7sbbtkohtqhvkc8j.xn--p1ai"

Actual result:


fix-idn-filter-validate-email (last revision 2011-11-25 08:41 UTC by enderstd at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-29 08:24 UTC] enderstd at gmail dot com
-Status: Open +Status: Closed
 [2011-11-29 08:24 UTC] enderstd at gmail dot com
This bug is duplicate for:
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun May 22 14:05:46 2022 UTC