X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fpassword%2FMWOldPassword.php;h=c48b6e61d57e32a4d98b8b709e27af53842107a4;hp=2150e562153f620155aa59f0b7ec09e36eb9f578;hb=4260b0f8a9bb89d92c39a61d8c48a31007b7240f;hpb=601519ee36462faabacf4547c9aefaf7e8726476 diff --git a/includes/password/MWOldPassword.php b/includes/password/MWOldPassword.php index 2150e56215..c48b6e61d5 100644 --- a/includes/password/MWOldPassword.php +++ b/includes/password/MWOldPassword.php @@ -36,13 +36,19 @@ class MWOldPassword extends ParameterizedPassword { } public function crypt( $plaintext ) { - global $wgPasswordSalt; - - if ( $wgPasswordSalt && count( $this->args ) === 1 ) { + if ( count( $this->args ) === 1 ) { + // Accept (but do not generate) salted passwords with :A: prefix. + // These are actually B-type passwords, but an error in a previous + // version of MediaWiki caused them to be written with an :A: + // prefix. $this->hash = md5( $this->args[0] . '-' . md5( $plaintext ) ); } else { $this->args = []; $this->hash = md5( $plaintext ); } + + if ( !is_string( $this->hash ) || strlen( $this->hash ) < 32 ) { + throw new PasswordError( 'Error when hashing password.' ); + } } }