|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-12-05 13:37 UTC] ant@php.net
[2009-01-19 17:25 UTC] d_kelsey at uk dot ibm dot com
[2009-02-14 10:13 UTC] moriyoshi@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 23:00:01 2025 UTC |
Description: ------------ The offset checking in mb_stripos and mb_strripos doesn't match the case sensitive equivalents with regard to character counts rather than byte counts. More importantly entering a negative offset in mb_strripos results in a "Offset not contained in string." message which was not expected. Suggested code changes. mb_stripos function add the check: if (offset < 0 || (unsigned long)offset > (unsigned long)mbfl_strlen(&old_haystack)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string."); RETURN_FALSE; } mb_strripos function add the check: if ((offset > 0 && offset > mbfl_strlen(&old_haystack)) || (offset < 0 && -offset > mbfl_strlen(&old_haystack))) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Offset is greater than the length of haystack string"); RETURN_FALSE; } php_mb_stripos function remove the check: if (offset < 0 || (unsigned long)offset > haystack.len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string."); break; } Reproduce code: --------------- <?php var_dump(mb_strripos("abc abc abc", "b", -3)); ?> Expected result: ---------------- int(5) Actual result: -------------- Warning: mb_strripos(): Offset not contained in string. in C:\udata-eclipse\p8\a.phpcode\testmb.php on line 2 bool(false)