php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80834 The idn_to_utf8 function returns an error when the URL has "-" at the end
Submitted: 2021-03-05 08:20 UTC Modified: 2021-03-05 10:30 UTC
From: kontakt at jinteractive dot pl Assigned: cmb (profile)
Status: Not a bug Package: *URL Functions
PHP Version: 7.4.16 OS: Windows, Centos
Private report: No CVE-ID: None
 [2021-03-05 08:20 UTC] kontakt at jinteractive dot pl
Description:
------------
The idn_to_utf8 function returns an error when the URL has a "-" sign at the end. 

Test script:
---------------
$x = idn_to_utf8('www.website.com/asa-asda-asd-.html');
if (!$x) 
	echo 'error';
else
	echo $x;
//return error


$x = idn_to_utf8('www.website.com/asa-asda-asd-');
if (!$x) 
	echo 'error';
else
	echo $x;
//return error


$x = idn_to_utf8('www.website.com/asa-asda-asd.html');
if (!$x) 
	echo 'error';
else
	echo $x;
// return url


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-05 10:30 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-03-05 10:30 UTC] cmb@php.net
Trailing hyphens are not allowed for INTL_IDNA_VARIANT_UTS46, what
is the default as of PHP 7.4.0.  If you had passed an $idna_info
and checked its 'errors' element, you had gotten 16, which is
IDNA_ERROR_TRAILING_HYPHEN.

Also note that idn_to_utf8() expects a domain name, not an URL.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Sep 16 12:03:37 2021 UTC