Validate status codes returned from the AbortLogin hook
authorGergő Tisza <gtisza@wikimedia.org>
Mon, 17 Aug 2015 23:08:00 +0000 (23:08 +0000)
committerBryanDavis <bdavis@wikimedia.org>
Sat, 24 Oct 2015 22:26:55 +0000 (22:26 +0000)
In case of a return value which is not in LoginForm::$statusCodes,
this results in a nicer error message instead of an array access error.

Bug: T109193
Change-Id: I64c955327c7dfc64807fa83d30538f3da66618bc

includes/specials/SpecialUserlogin.php

index de69b9d..8facb35 100644 (file)
@@ -783,8 +783,10 @@ class LoginForm extends SpecialPage {
                // Give general extensions, such as a captcha, a chance to abort logins
                $abort = self::ABORTED;
                if ( !Hooks::run( 'AbortLogin', array( $u, $this->mPassword, &$abort, &$msg ) ) ) {
+                       if ( !in_array( $abort, self::$statusCodes, true ) ) {
+                               throw new Exception( 'Invalid status code returned from AbortLogin hook: ' . $abort );
+                       }
                        $this->mAbortLoginErrorMsg = $msg;
-
                        return $abort;
                }