Jackmcbarn has uploaded a new change for review.
https://gerrit.wikimedia.org/r/108220
Change subject: Don't pass empty strings to strpos
......................................................................
Don't pass empty strings to strpos
When an empty parameter is passed to a function using strpos, such as when
an extra comma appears at the end of contains_any's parameter list, don't
call strpos on the empty string.
Bug: 60203
Change-Id: I6221a01ad1ec9090de7bfc1d9d6583f22ba0eb2e
---
M AbuseFilter.parser.php
1 file changed, 13 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter
refs/changes/20/108220/1
diff --git a/AbuseFilter.parser.php b/AbuseFilter.parser.php
index 86582b9..83ba736 100644
--- a/AbuseFilter.parser.php
+++ b/AbuseFilter.parser.php
@@ -1787,8 +1787,12 @@
$haystack = $args[1]->toString();
$count = 0;
- while ( ( $offset = strpos( $haystack, $needle, $offset
+ 1 ) ) !== false ) {
- $count++;
+
+ // Bug #60203: Keep empty parameters from causing PHP
warnings
+ if ( $needle !== '' ) {
+ while ( ( $offset = strpos( $haystack, $needle,
$offset + 1 ) ) !== false ) {
+ $count++;
+ }
}
}
@@ -1910,7 +1914,8 @@
} else {
$ok = false;
foreach ( $searchStrings as $needle ) {
- if ( strpos( $s, $needle ) !== false ) {
+ // Bug #60203: Keep empty parameters from
causing PHP warnings
+ if ( $needle !== '' && strpos( $s, $needle )
!== false ) {
$ok = true;
break;
}
@@ -2100,6 +2105,11 @@
$haystack = $args[0]->toString();
$needle = $args[1]->toString();
+ // Bug #60203: Keep empty parameters from causing PHP warnings
+ if ( $needle === '' ) {
+ return new AFPData( AFPData::DInt, -1 );
+ }
+
if ( isset( $args[2] ) ) {
$offset = $args[2]->toInt();
--
To view, visit https://gerrit.wikimedia.org/r/108220
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6221a01ad1ec9090de7bfc1d9d6583f22ba0eb2e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits