php.net |  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
Description:
------------
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:
---------------
error_reporting(E_ALL);
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";
        var_dump($err);
    } 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.

Patches

Pull Requests

History

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] <http://tools.ietf.org/html/rfc2181#section-11>
[2] <http://www.php.net/manual/en/function.idn-to-ascii.php#refsect1-function.idn-to-ascii-returnvalues>
 [2014-07-07 05:40 UTC] stas@php.net
-Status: Open +Status: Not a bug
 [2014-07-07 05:40 UTC] stas@php.net
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: Sun Dec 22 06:01:30 2024 UTC