Fix #72320: iconv_substr returns false for empty strings#2043
Merged
php-pulls merged 1 commit intophp:PHP-7.0from Aug 29, 2016
Merged
Fix #72320: iconv_substr returns false for empty strings#2043php-pulls merged 1 commit intophp:PHP-7.0from
php-pulls merged 1 commit intophp:PHP-7.0from
Conversation
For consistency with substr() and mb_substr(), iconv_substr() should return an empty string instead of FALSE, when $offset == iconv_strlen($str).
Member
Author
|
The failing checks appear to be unrelated to this patch. |
Member
|
Given the unexpectedly large fallout the change for substr had, I don't think it should go into 5.6 (though iconv_substr is of course used much less). One of 7.0 (because substr changed here) or 7.1 (the conservative choice) sounds fine to me. |
Member
Author
|
@weltling Is it okay to treat this issue as bug and fix it in PHP 7.0+, or do you think we should go with PHP 7.1+ only? |
|
@cmb69 I see some usage here and there, but couldn't find issues in OSS apps regarding this change so far. And iconv_substr is indeed used rarely, so I don't really see what would prevent to give this change a try in 7.0. Thanks. |
Member
Author
|
@weltling Thanks for having a look at this issue. I'm going to merge into 7.0+. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For consistency with substr() and mb_substr(), iconv_substr() should return
an empty string instead of FALSE, when $offset == iconv_strlen($str).
In my opinion, the question is not whether to apply this patch, but rather against which PHP version. According to the docs ("If str is shorter than offset characters long, FALSE will be returned.") this is a bug, and so should be applied against PHP 5.6+. However, this change causes a BC break, so it might best be applied to master only. Then again, the respective behavior of substr() has been changed as of PHP 7, so a reasonable compromise would be to apply the fix against PHP 7.0 or maybe PHP 7.1.
Thoughts?