File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -2100,6 +2100,17 @@ PHP_FUNCTION(mb_strpos)
2100
2100
RETURN_FALSE ;
2101
2101
}
2102
2102
2103
+ if (offset != 0 ) {
2104
+ size_t slen = mbfl_strlen (& haystack );
2105
+ if (offset < 0 ) {
2106
+ offset += slen ;
2107
+ }
2108
+ if (offset < 0 || offset > slen ) {
2109
+ zend_value_error ("Offset not contained in string" );
2110
+ RETURN_THROWS ();
2111
+ }
2112
+ }
2113
+
2103
2114
n = mbfl_strpos (& haystack , & needle , offset , reverse );
2104
2115
if (!mbfl_is_error (n )) {
2105
2116
RETVAL_LONG (n );
@@ -2116,9 +2127,6 @@ PHP_FUNCTION(mb_strpos)
2116
2127
case 8 :
2117
2128
zend_value_error ("Argument is empty" );
2118
2129
RETURN_THROWS ();
2119
- case 16 :
2120
- zend_value_error ("Offset not contained in string" );
2121
- RETURN_THROWS ();
2122
2130
default :
2123
2131
zend_value_error ("Unknown error in mb_strpos" );
2124
2132
RETURN_THROWS ();
You can’t perform that action at this time.
0 commit comments