php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: enderstd at gmail dot com
New email:
PHP Version: OS:

 

 [2011-11-25 08:40 UTC] enderstd at gmail dot com
Description:
------------
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:
---------------
<?php

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

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

Actual result:
--------------
bool(false)

Patches

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

Pull Requests

History

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: https://bugs.php.net/bug.php?id=55478
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 21:01:27 2024 UTC