From b28171af6f46f8c3c74898ba6c3c71a01a625764 Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Mon, 26 Oct 2009 22:58:39 +0000 Subject: [PATCH] * Any strings returned by the isValidPassword hook are now shown as error messages instead of MediaWiki thinking that the hook said the password was valid. * The error message shown in Special:ChangePassword now parses wiki markup --- RELEASE-NOTES | 3 +++ includes/User.php | 10 ++++++---- includes/specials/SpecialResetpass.php | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2abe831126..8adfccbda8 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -598,6 +598,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 18019) Users are now warned when moving a file to a name in use on a shared repository and only users with the 'reupload-shared' permission can complete the move. +* Any strings returned by the isValidPassword hook are now shown as error messages + instead of MediaWiki thinking that the hook said the password was valid. +* The error message shown in Special:ChangePassword now parses wiki markup == API changes in 1.16 == diff --git a/includes/User.php b/includes/User.php index d4cfbd7852..0b53fe6863 100644 --- a/includes/User.php +++ b/includes/User.php @@ -621,7 +621,7 @@ class User { * Is the input a valid password for this user? * * @param $password String Desired password - * @return bool True or false + * @return mixed: bool True or false or a message key explaining why the password is invalid */ function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang; @@ -645,14 +645,16 @@ class User { function getPasswordValidity( $password ) { global $wgMinimalPasswordLength, $wgContLang; - if ( !$this->isValidPassword( $password ) ) { + if ( ( $result = $this->isValidPassword( $password ) ) === false ) { if( strlen( $password ) < $wgMinimalPasswordLength ) { return 'passwordtooshort'; } elseif ( $wgContLang->lc( $password ) == $wgContLang->lc( $this->mName ) ) { return 'password-name-match'; } - } else { + } elseif( $result === true ) { return true; + } else { + return $result; //the isValidPassword hook set a string $result and returned false } } @@ -1768,7 +1770,7 @@ class User { throw new PasswordError( wfMsg( 'password-change-forbidden' ) ); } - if( !$this->isValidPassword( $str ) ) { + if( $this->isValidPassword( $str ) !== true ) { global $wgMinimalPasswordLength; $valid = $this->getPasswordValidity( $str ); throw new PasswordError( wfMsgExt( $valid, array( 'parsemag' ), diff --git a/includes/specials/SpecialResetpass.php b/includes/specials/SpecialResetpass.php index 3e49354488..86bf0b875b 100644 --- a/includes/specials/SpecialResetpass.php +++ b/includes/specials/SpecialResetpass.php @@ -68,7 +68,7 @@ class SpecialResetpass extends SpecialPage { function error( $msg ) { global $wgOut; - $wgOut->addHTML( Xml::element('p', array( 'class' => 'error' ), $msg ) ); + $wgOut->addWikiText( '
' . $msg . '
' ); } function showForm() { -- 2.20.1