#47102 [Opn]: strripos issues unepxected warning with UNICODE haystack
| From: | wharmby at uk dot ibm dot com | Date: | Thu, 15 Jan 2009 13:43:03 +0000 |
| Subject: | #47102 [Opn]: strripos issues unepxected warning with UNICODE haystack | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-132896@lists.php.net to get a copy of this message | ||
ID: 47102
User updated by: wharmby at uk dot ibm dot com
Reported By: wharmby at uk dot ibm dot com
Status: Open
Bug Type: Strings related
Operating System: Windows XP
PHP Version: 6CVS-2009-01-14 (snap)
New Comment:
8 new tests for strripos() just checked into CVS. 3 fail on PHP6
because of this bug and have XFAIL sections which need removing once
this bug is fixed. They are:
ext/standard/tests/strings/strripos_basic2
ext/standard/tests/strings/strripos_variation1
ext/standard/tests/strings/strripos_variation2
Previous Comments:
------------------------------------------------------------------------
[2009-01-14 16:06:32] wharmby at uk dot ibm dot com
Description:
------------
I get an unexpected warning msg when I specify an haystack with a
non-zero offset.
I think the problem lies in the following code in ext/standard/string.c
2913 if (haystack_type == IS_UNICODE) {
2914 if (offset >= 0) {
2915 U16_FWD_N(haystack.u, cu_offset, haystack_len, offset);
2916 if (cu_offset > haystack_len - needle_len) {
2917 php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Offset is greater
than the length of haystack string");
2918 RETURN_FALSE;
2919 }
2920 u_p = haystack.u + cu_offset;
2921 u_e = haystack.u + haystack_len - needle_len;
2922 } else {
If (cu_offset > haystack_len - needle_len) then FALSE should be
returned but the warning is bogus; that should only be output if
cu_offset > haystack_len.
Reproduce code:
---------------
<?php
$haystack = "abcdefg";
$needle = "abcdefg";
var_dump( strripos($haystack, $needle, 0) );
var_dump( strripos($haystack, $needle, 1) );
?>
Expected result:
----------------
int(0)
bool(false)
Actual result:
--------------
int(0)
bool(false)
PHP Notice: strripos(): Offset is greater than the length of haystack
string in .... etc
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47102&edit=1