jenkins-bot has submitted this change and it was merged.

Change subject: Protect against undefined array access
......................................................................


Protect against undefined array access

explode() can return less than two array items if the line is
improperly formatted. list() yells at you then.

Skip such lines since we can't handle them anyway.

Bug: T108958
Change-Id: I95ced04f4242587fb35956ab2dbd78213ca793e7
---
M includes/Hooks.php
1 file changed, 8 insertions(+), 1 deletion(-)

Approvals:
  20after4: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Hooks.php b/includes/Hooks.php
index 53f7463..0711303 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -364,7 +364,14 @@
                }
 
                foreach ( $lines as $line ) {
-                       list( $k, $v ) = explode( ':', $line, 2 );
+                       $linePieces = explode( ':', $line, 2 );
+                       if ( count( $linePieces < 2 ) ) {
+                               // Skip improperly formatted lines without a 
key:value
+                               continue;
+                       }
+                       $k = $linePieces[0];
+                       $v = $linePieces[1];
+
                        switch( $k ) {
                        case 'max_errors' :
                                if ( is_numeric( $v ) && $v >= 1 && $v <= 
$wgCirrusSearchPhraseSuggestMaxErrorsHardLimit ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/231332
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I95ced04f4242587fb35956ab2dbd78213ca793e7
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>
Gerrit-Reviewer: 20after4 <[email protected]>
Gerrit-Reviewer: DCausse <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to