mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 13:46:48 +00:00
Avoid passing invalid offset to mb_strpos
Bug: T285978 Change-Id: I3d100fd05f34fe3b01ecbbce5361badc613f9406
This commit is contained in:
parent
6dc2c068b5
commit
069fa064f5
|
@ -1268,7 +1268,11 @@ class AbuseFilterCachingParser extends AFPTransitionBase {
|
|||
if ( $needle === '' ) {
|
||||
return new AFPData( AFPData::DINT, -1 );
|
||||
}
|
||||
|
||||
// Special handling for when the offset is not contained in $haystack. PHP can emit a warning
|
||||
// or throw an error depending on the version (T285978). TODO Should we also throw?
|
||||
if ( $offset > mb_strlen( $haystack ) ) {
|
||||
return new AFPData( AFPData::DINT, -1 );
|
||||
}
|
||||
$result = mb_strpos( $haystack, $needle, $offset );
|
||||
|
||||
if ( $result === false ) {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
strpos( "foobarfoo", "foo" ) === 0 &
|
||||
strpos( "foobarfoo", "" ) === -1 &
|
||||
strpos( "foobarfoo", "foo", 1 ) === 6 &
|
||||
strpos( "foobarfoo", "lol" ) === -1
|
||||
strpos( "foobarfoo", "lol" ) === -1 &
|
||||
/* Offset not contained in the haystack */
|
||||
strpos( "foo", "o", 123456 ) === -1
|
||||
|
|
Loading…
Reference in a new issue