|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2016-06-03 12:34 UTC] cmb@php.net
-Status: Open
+Status: Verified
[2016-06-03 12:34 UTC] cmb@php.net
[2016-08-29 23:25 UTC] cmb@php.net
[2016-08-29 23:25 UTC] cmb@php.net
-Status: Verified
+Status: Closed
[2016-10-17 10:10 UTC] bwoebi@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
Description: ------------ From iconv.c... _php_iconv_substr returns success if the offset is more than or equal to the character length of the input string... if ((size_t)offset >= total_len) { return PHP_ICONV_ERR_SUCCESS; } ... Then in the calling function (iconv_substr) we check the result... if (err == PHP_ICONV_ERR_SUCCESS && ZSTR_LEN(str) > 0 && retval.s != NULL) { RETURN_NEW_STR(retval.s); } smart_str_free(&retval); RETURN_FALSE; Note how this will always return false for an empty input string. Additionally it will also return false if offset==total_len, because retval.s will not have been set at the point of _php_iconv_substr returning (as indicated). The documentation says: "If str is shorter than offset characters long, FALSE will be returned." I believe the documentation describes the correct behaviour. 0 characters is not shorter than a 0 offset. mb_substr and substr are confirmed to work correctly. Likely nobody has noticed this bug until now because false and '' are similar, but it matters for us strict type users, and when interacting with persistency layers. Test script: --------------- var_dump(iconv_substr('',0,10,'utf-8')); Expected result: ---------------- string(0) "" Actual result: -------------- bool(false)