php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59652 idn_to_ascii returns invalid url for utf-8 in host
Submitted: 2011-03-05 18:22 UTC Modified: 2011-03-05 18:48 UTC
From: jctest at hotmail dot com Assigned:
Status: Not a bug Package: idn (PECL)
PHP Version: 5.3.3 OS: Ubuntu 9.3
Private report: No CVE-ID: None
 [2011-03-05 18:22 UTC] jctest at hotmail dot com
Description:
------------
Hi,
I am trying to encode urls with the function idn_to_ascii. It 
works well except when the host contains utf-8 characters, 
like ? ? and ? and without a protocol. It returns OK, but it 
isn't.

Thank you.

Reproduce code:
---------------
$url = "http://t?st.se";
$asciiurl = idn_to_ascii($url);

Although $url = "http://www.t?st.se" returns expected result. Also $url = "http://somethingelse.t?st.se" returns expected result. It's just when http://hostwith???.com it fails.

Expected result:
----------------
Expected url returned: http://www.xn--tst-qla.se

Actual result:
--------------
The url returned: xn--http://tst-x5a.se (not a valid http 
address)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-05 18:33 UTC] jctest at hotmail dot com
Sorry, the expected returned result should be http://xn--tst-
qla.se (without www)
 [2011-03-05 18:48 UTC] johannes at schlueters dot de
Thank you for taking the time to write to us, but this is not
a bug.

The function is not supposed to work on a URL but a host name. Use parse_url() if needed.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Nov 27 06:03:14 2021 UTC