* (bug 4071) Generate passwords long enough for $wgMinimalPasswordLength
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 1 Dec 2005 08:15:08 +0000 (08:15 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 1 Dec 2005 08:15:08 +0000 (08:15 +0000)
Patch by Sven Klemm, http://bugzilla.wikimedia.org/attachment.cgi?id=1104&action=view

RELEASE-NOTES
includes/User.php

index d09fd1c..40e5509 100644 (file)
@@ -265,6 +265,7 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 3922) Further tweaks to bidi overrides in category list for old
   versions of Safari and Konqueror
 * Don't die() when update.php reaches the end of the warning count
+* (bug 4071) Generate passwords long enough for $wgMinimalPasswordLength
 
 
 === Caveats ===
index 551aa23..144c783 100644 (file)
@@ -268,13 +268,16 @@ class User {
         * @todo Check what is doing really [AV]
         */
        function randomPassword() {
+               global $wgMinimalPasswordLength;
                $pwchars = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz';
                $l = strlen( $pwchars ) - 1;
 
-               $np = $pwchars{mt_rand( 0, $l )} . $pwchars{mt_rand( 0, $l )} .
-                 $pwchars{mt_rand( 0, $l )} . chr( mt_rand(48, 57) ) .
-                 $pwchars{mt_rand( 0, $l )} . $pwchars{mt_rand( 0, $l )} .
-                 $pwchars{mt_rand( 0, $l )};
+               $pwlength = max( 7, $wgMinimalPasswordLength );
+               $digit = mt_rand(0, $pwlength - 1);
+               $np = '';
+               for ( $i = 0; $i < $pwlength; $i++ ) {
+                       $np .= $i == $digit ? chr( mt_rand(48, 57) ) : $pwchars{ mt_rand(0, $l)};
+               }
                return $np;
        }