|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67084 The "idn_to_ascii()" function silently fails on long domains
Submitted: 2014-04-16 10:01 UTC Modified: 2014-07-07 05:40 UTC
From: lomakin dot d at gmail dot com Assigned:
Status: Not a bug Package: intl (PECL)
PHP Version: 5.5.11 OS: Linux
Private report: No CVE-ID: None
 [2014-04-16 10:01 UTC] lomakin dot d at gmail dot com
In case the $domain argument has a value of 68+ characters long the function silently returns (bool) false and doesn't indicate an exceptional case.

Test script:
ini_set('display_errors', 'on');

foreach ([67, 68] as $i) {
    $err = 0;

    $domain = str_pad('.com', $i, 'a', STR_PAD_LEFT);
    $asciiDomain = idn_to_ascii($domain, $err);

    if (false === $asciiDomain) {
        echo "Length limit is $i. Error '$err'. Stop.\n";
    } else {
        echo "Length $i. asciiDomain is '$asciiDomain'. OK\n";

Expected result:
PHP should at least report a warning about wrong input.

Actual result:
The function just returns (bool) false without any error indication.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-05-12 18:36 UTC] cmbecker69 at gmx dot de
There is no 68 character limit regarding the domain name, but
rather a 63 character limit regarding each label, which is not
imposed by PHP but rather by the DNS[1].

Anyway, IMHO the behavior of idn_to_ascii() is fine, as the client
can easily check the return value. Furthermore the behavior is
well documented[2], so I don't regard this as bug.

[1] <>
[2] <>
 [2014-07-07 05:40 UTC]
-Status: Open +Status: Not a bug
 [2014-07-07 05:40 UTC]
This seems to be a valid behavior. The IDN library from ICU limits the label length, and the error is available via intl_get_error_code() and intl_get_error_message().
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 03:01:28 2024 UTC