php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79705 Functions "intl_get_error_code", "intl_get_error_message" work incorrectly
Submitted: 2020-06-16 09:49 UTC Modified: 2020-06-16 11:57 UTC
From: alex dot vl dot tihon at gmail dot com Assigned:
Status: Open Package: Unknown/Other Function
PHP Version: 7.4.7 OS: Ubuntu 20.04 LTS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alex dot vl dot tihon at gmail dot com
New email:
PHP Version: OS:

 

 [2020-06-16 09:49 UTC] alex dot vl dot tihon at gmail dot com
Description:
------------
In php7.4 the functions "intl_get_error_code", "intl_get_error_message" do not return correct error code/message despite "idn_to_ascii" returns FALSE.

The real error code can be retrieved from 'idna_info' array passed to "idn_to_ascii" function. But "intl_get_error_code", "intl_get_error_message" should also work for the backward compatibility.

Test script:
---------------
// PHP 7.3.x
$result=idn_to_ascii('.pm--domain.com', IDNA_DEFAULT, INTL_IDNA_VARIANT_2003);
echo intl_get_error_code(); // 66567
echo intl_get_error_message(); // idn_to_ascii: cannot convert to ASCII: U_IDNA_ZERO_LENGTH_LABEL_ERROR
// PHP 7.4.x
$result=idn_to_ascii('.pm--domain.com.', IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $data);
echo intl_get_error_code(); // 0
echo intl_get_error_message(); // U_ZERO_ERROR
var_dump($data);
/**array(3) {
  ["result"]=>
  string(16) ".pm--domain.com."
  ["isTransitionalDifferent"]=>
  bool(false)
  ["errors"]=>
  int(33)
}*/

Expected result:
----------------
echo intl_get_error_code(); // the last error code should be returned
echo intl_get_error_message(); // the last error message should be returned


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-16 11:57 UTC] cmb@php.net
The behavior is not specific to PHP 7.4; it works the same for PHP
7.3[1].  I don't agree that anything should be changed for BC
reasons; after all, INTL_IDNA_VARIANT_2003 is deprecated as of PHP
7.2.0, and I think you're better off to not use this for PHP 7.3
code.

[1] <https://3v4l.org/aK0Es>
 [2020-06-16 16:08 UTC] atikhonov at plesk dot com
Maybe I mislead you with the usage of the "INTL_IDNA_VARIANT_2003" constant. But the issue is in the incorrect behaviour of "intl_get_error_code", "intl_get_error_message" for PHP 7.4.x if "idn_to_ascii" function returns "FALSE".
Please, take a look:
https://3v4l.org/0ekbB 

For PHP 7.4.x "idn_to_ascii" function returns FALSE. But at the same time the "intl_get_error_code" returns code 0 and "intl_get_error_message" returns U_ZERO_ERROR. I think it is incorrect. The last error code/message should be returned as for PHP 7.2.0 - 7.2.31, 7.3.10 - 7.3.19
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 12:01:31 2024 UTC