r81445 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81444‎ | r81445 | r81446 >
Date:12:24, 3 February 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17: Take out r70520 (JS password strength checker)
Modified paths:
  • /branches/REL1_17/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_17/phase3/includes/OutputPage.php (modified) (history)
  • /branches/REL1_17/phase3/includes/specials/SpecialResetpass.php (modified) (history)
  • /branches/REL1_17/phase3/includes/specials/SpecialUserlogin.php (modified) (history)
  • /branches/REL1_17/phase3/includes/templates/Userlogin.php (modified) (history)
  • /branches/REL1_17/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /branches/REL1_17/phase3/maintenance/language/messages.inc (modified) (history)
  • /branches/REL1_17/phase3/resources/Resources.php (modified) (history)
  • /branches/REL1_17/phase3/skins/common/password.css (deleted) (history)
  • /branches/REL1_17/phase3/skins/common/password.js (deleted) (history)

Diff [purge]

Index: branches/REL1_17/phase3/languages/messages/MessagesEn.php
@@ -1149,15 +1149,6 @@
11501150 'php-mail-error' => '$1', # do not translate or duplicate this message to other languages
11511151 'php-mail-error-unknown' => "Unknown error in PHP's mail() function",
11521152
1153 -# JavaScript password checks
1154 -'password-strength' => 'Estimated password strength: $1',
1155 -'password-strength-bad' => 'BAD',
1156 -'password-strength-mediocre' => 'mediocre',
1157 -'password-strength-acceptable' => 'acceptable',
1158 -'password-strength-good' => 'good',
1159 -'password-retype' => 'Retype password here',
1160 -'password-retype-mismatch' => 'Passwords do not match',
1161 -
11621153 # Password reset dialog
11631154 'resetpass' => 'Change password',
11641155 'resetpass_announce' => 'You logged in with a temporary e-mailed code.
Index: branches/REL1_17/phase3/RELEASE-NOTES
@@ -181,8 +181,6 @@
182182 ** When several pages are given the same sort key, they sort by their names
183183 instead of randomly.
184184 * (bug 23848) Add {{ARTICLEPATH}} Magic Word.
185 -* JavaScript-based password complexity checker on account creation and
186 - password change.
187185 * The HTML ID's generated for sections are now much prettier when they contain
188186 punctuation or non-English letters, so a section named "Hello?" will now
189187 result in a URL ending in "#Hello?" rather than "#Hello.3F".
Index: branches/REL1_17/phase3/resources/Resources.php
@@ -460,11 +460,6 @@
461461 'dependencies' => 'mediawiki.legacy.wikibits',
462462 'messages' => array( 'search-mwsuggest-enabled', 'search-mwsuggest-disabled' ),
463463 ),
464 - 'mediawiki.legacy.password' => array(
465 - 'scripts' => 'skins/common/password.js',
466 - 'styles' => 'skins/common/password.css',
467 - 'dependencies' => 'mediawiki.legacy.wikibits',
468 - ),
469464 'mediawiki.legacy.prefs' => array(
470465 'scripts' => 'skins/common/prefs.js',
471466 'dependencies' => array( 'mediawiki.legacy.wikibits', 'mediawiki.legacy.htmlform' ),
Index: branches/REL1_17/phase3/maintenance/language/messages.inc
@@ -468,15 +468,6 @@
469469 'php-mail-error',
470470 'php-mail-error-unknown',
471471 ),
472 - 'passwordstrength' => array(
473 - 'password-strength',
474 - 'password-strength-bad',
475 - 'password-strength-mediocre',
476 - 'password-strength-acceptable',
477 - 'password-strength-good',
478 - 'password-retype',
479 - 'password-retype-mismatch',
480 - ),
481472 'resetpass' => array(
482473 'resetpass',
483474 'resetpass_announce',
Index: branches/REL1_17/phase3/skins/common/password.css
@@ -1,17 +0,0 @@
2 -span.mw-password-bad {
3 - background: red;
4 - color: yellow;
5 - font-weight: bold;
6 -}
7 -
8 -.mw-password-mediocre {
9 - background: yellow;
10 -}
11 -
12 -.mw-password-acceptable {
13 - background: silver;
14 -}
15 -
16 -.mw-password-good {
17 - background: green;
18 -}
\ No newline at end of file
Index: branches/REL1_17/phase3/skins/common/password.js
@@ -1,131 +0,0 @@
2 -/**
3 - * Password strength checker
4 - * @license WTFPL 2.0
5 - * All scores are ranged approximately 0 (total disaster) - 100 (_looks_ great)
6 - * @todo Check for popular passwords and keyboard sequences (QWERTY, etc)
7 - */
8 -
9 -// Estimates how hard it would be to pick the password using brute force
10 -window.bruteForceComplexity = function( pwd ) {
11 - var score = pwd.length * 5;
12 -
13 - var regexes = [
14 - /[a-z]/,
15 - /[A-Z]/,
16 - /[0-9]/,
17 - /[-_;:\.,'"`~!@#$%\^&\*\(\)\[\]\{\} ]/
18 - ];
19 -
20 - var charClasses = 0;
21 - for ( var i=0; i< regexes.length; i++ ) {
22 - if ( pwd.match( regexes[i] ) ) {
23 - charClasses++;
24 - }
25 - }
26 -
27 - var matches = pwd.match( /[\x80-\uFFFF]/g );
28 - if ( matches ) {
29 - charClasses++;
30 -
31 - var s = matches.join( '' );
32 - // poor man's isUpper() and isLower()
33 - if ( s != s.toLowerCase() && s != s.toUpperCase() ) {
34 - charClasses++;
35 - }
36 - }
37 - score += ( charClasses - 1 ) * 10;
38 -
39 - return score;
40 -};
41 -
42 -// Calculates a penalty to brute force score due to character repetition
43 -window.repetitionAdjustment = function( pwd ) {
44 - var unique = '';
45 - for ( var i=0; i< pwd.length; i++ ) {
46 - if ( unique.indexOf( pwd[i] ) < 0 ) {
47 - unique += pwd[i];
48 - }
49 - }
50 - var ratio = pwd.length / unique.length - 0.4; // allow up to 40% repetition, reward for less, penalize for more
51 -
52 - return ratio * 10;
53 -};
54 -
55 -// Checks how many simple sequences ("abc", "321") are there in the password
56 -window.sequenceScore = function( pwd ) {
57 - pwd = pwd.concat( '\0' );
58 - var score = 100, sequence = 1;
59 - for ( var i = 1; i < pwd.length; i++ ) {
60 - if ( pwd.charCodeAt( i ) == pwd.charCodeAt(i - 1) + 1 ) {
61 - sequence++;
62 - } else {
63 - if ( sequence > 2 ) {
64 - score -= sequence * 7;
65 - }
66 - sequence = 1;
67 - }
68 - }
69 - for ( var i = 1; i < pwd.length; i++ ) {
70 - if ( pwd.charCodeAt( i ) == pwd.charCodeAt(i - 1) - 1 ) {
71 - sequence++;
72 - } else {
73 - if ( sequence > 2 ) {
74 - score -= Math.sqrt( sequence ) * 15;
75 - }
76 - sequence = 1;
77 - }
78 - }
79 - return score;
80 -};
81 -
82 -(function( $ ) {
83 - function passwordChanged() {
84 - retypeChanged();
85 - var pwd = $( passwordSecurity.password ).val();
86 - if ( pwd == '' ) {
87 - $( '#password-strength' ).html( '' );
88 - return;
89 - }
90 - if ( pwd.length > 100 ) pwd = pwd.slice( 0, 100 );
91 - var scores = [
92 - bruteForceComplexity( pwd ),
93 - repetitionAdjustment( pwd ),
94 - sequenceScore( pwd )
95 - ];
96 -
97 - var score = Math.min( scores[0] - scores[1], scores[2] );
98 - var result = 'good';
99 - if ( score < 40 ) {
100 - result = 'bad';
101 - } else if ( score < 60 ) {
102 - result = 'mediocre';
103 - } else if ( score < 80 ) {
104 - result = 'acceptable';
105 - }
106 - var message = '<span class="mw-password-' + result + '">' + passwordSecurity.messages['password-strength-' + result]
107 - + '</span>';
108 - $( '#password-strength' ).html(
109 - passwordSecurity.messages['password-strength'].replace( '$1', message )
110 - //+ scores
111 - );
112 - }
113 -
114 - function retypeChanged() {
115 - var pwd = $( passwordSecurity.password ).val();
116 - var retype = $( passwordSecurity.retype ).val();
117 - var message;
118 - if ( pwd == '' || pwd == retype ) {
119 - message = '';
120 - } else if ( retype == '' ) {
121 - message = passwordSecurity.messages['password-retype'];
122 - } else {
123 - message = passwordSecurity.messages['password-retype-mismatch'];
124 - }
125 - $( '#password-retype' ).html( message );
126 - }
127 -
128 - $( document ).ready( function() {
129 - $( passwordSecurity.password ).bind( 'keyup change', passwordChanged );
130 - $( passwordSecurity.retype ).bind( 'keyup change', retypeChanged );
131 - })
132 -})(jQuery);
Index: branches/REL1_17/phase3/includes/specials/SpecialUserlogin.php
@@ -959,10 +959,6 @@
960960 }
961961
962962 if ( $this->mType == 'signup' ) {
963 - global $wgLivePasswordStrengthChecks;
964 - if ( $wgLivePasswordStrengthChecks ) {
965 - $wgOut->addPasswordSecurity( 'wpPassword2', 'wpRetype' );
966 - }
967963 $template = new UsercreateTemplate();
968964 $q = 'action=submitlogin&type=signup';
969965 $linkq = 'type=login';
Index: branches/REL1_17/phase3/includes/specials/SpecialResetpass.php
@@ -106,11 +106,8 @@
107107 }
108108
109109 function showForm() {
110 - global $wgOut, $wgUser, $wgRequest, $wgLivePasswordStrengthChecks;
 110+ global $wgOut, $wgUser, $wgRequest;
111111
112 - if ( $wgLivePasswordStrengthChecks ) {
113 - $wgOut->addPasswordSecurity( 'wpNewPassword', 'wpRetype' );
114 - }
115112 $self = $this->getTitle();
116113 if ( !$this->mUserName ) {
117114 $this->mUserName = $wgUser->getName();
@@ -146,10 +143,10 @@
147144 wfMsgExt( 'resetpass_text', array( 'parse' ) ) . "\n" .
148145 Xml::openElement( 'table', array( 'id' => 'mw-resetpass-table' ) ) . "\n" .
149146 $this->pretty( array(
150 - array( 'wpName', 'username', 'text', $this->mUserName, '' ),
151 - array( 'wpPassword', $oldpassMsg, 'password', $this->mOldpass, '' ),
152 - array( 'wpNewPassword', 'newpassword', 'password', null, '<div id="password-strength"></div>' ),
153 - array( 'wpRetype', 'retypenew', 'password', null, '<div id="password-retype"></div>' ),
 147+ array( 'wpName', 'username', 'text', $this->mUserName ),
 148+ array( 'wpPassword', $oldpassMsg, 'password', $this->mOldpass ),
 149+ array( 'wpNewPassword', 'newpassword', 'password', null ),
 150+ array( 'wpRetype', 'retypenew', 'password', null ),
154151 ) ) . "\n" .
155152 $rememberMe .
156153 "<tr>\n" .
@@ -168,7 +165,7 @@
169166 function pretty( $fields ) {
170167 $out = '';
171168 foreach ( $fields as $list ) {
172 - list( $name, $label, $type, $value, $extra ) = $list;
 169+ list( $name, $label, $type, $value ) = $list;
173170 if( $type == 'text' ) {
174171 $field = htmlspecialchars( $value );
175172 } else {
@@ -189,8 +186,9 @@
190187 else
191188 $out .= wfMsgHtml( $label );
192189 $out .= "</td>\n";
193 - $out .= "\t<td class='mw-input'>$field</td>\n";
194 - $out .= "\t<td>$extra</td>\n";
 190+ $out .= "\t<td class='mw-input'>";
 191+ $out .= $field;
 192+ $out .= "</td>\n";
195193 $out .= "</tr>";
196194 }
197195 return $out;
Index: branches/REL1_17/phase3/includes/OutputPage.php
@@ -2088,27 +2088,6 @@
20892089 }
20902090 }
20912091
2092 - /**
2093 - * Adds JS-based password security checker
2094 - * @param $passwordId String ID of input box containing password
2095 - * @param $retypeId String ID of input box containing retyped password
2096 - * @return none
2097 - */
2098 - public function addPasswordSecurity( $passwordId, $retypeId ) {
2099 - $data = array(
2100 - 'password' => '#' . $passwordId,
2101 - 'retype' => '#' . $retypeId,
2102 - 'messages' => array(),
2103 - );
2104 - foreach ( array( 'password-strength', 'password-strength-bad', 'password-strength-mediocre',
2105 - 'password-strength-acceptable', 'password-strength-good', 'password-retype', 'password-retype-mismatch'
2106 - ) as $message ) {
2107 - $data['messages'][$message] = wfMsg( $message );
2108 - }
2109 - $this->addScript( Html::inlineScript( 'var passwordSecurity=' . FormatJson::encode( $data ) ) );
2110 - $this->addModules( 'mediawiki.legacy.password' );
2111 - }
2112 -
21132092 /** @deprecated */
21142093 public function errorpage( $title, $msg ) {
21152094 wfDeprecated( __METHOD__ );
Index: branches/REL1_17/phase3/includes/templates/Userlogin.php
@@ -198,7 +198,6 @@
199199 'autofocus'
200200 ) ); ?>
201201 </td>
202 - <td></td>
203202 </tr>
204203 <tr>
205204 <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
@@ -211,7 +210,6 @@
212211 'size' => '20'
213212 ) + User::passwordChangeInputAttribs() ); ?>
214213 </td>
215 - <td><div id="password-strength"></div></td>
216214 </tr>
217215 <?php if( $this->data['usedomain'] ) {
218216 $doms = "";
@@ -227,7 +225,6 @@
228226 <?php echo $doms ?>
229227 </select>
230228 </td>
231 - <td></td>
232229 </tr>
233230 <?php } ?>
234231 <tr>
@@ -241,7 +238,6 @@
242239 'size' => '20'
243240 ) + User::passwordChangeInputAttribs() ); ?>
244241 </td>
245 - <td><div id="password-retype"></div></td>
246242 </tr>
247243 <tr>
248244 <?php if( $this->data['useemail'] ) { ?>
@@ -262,13 +258,12 @@
263259 } ?>
264260 </div>
265261 </td>
266 - <td></td>
267262 <?php } ?>
268263 <?php if( $this->data['userealname'] ) { ?>
269264 </tr>
270265 <tr>
271266 <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
272 - <td class="mw-input" colspan="2">
 267+ <td class="mw-input">
273268 <input type='text' class='loginText' name="wpRealName" id="wpRealName"
274269 tabindex="6"
275270 value="<?php $this->text('realname') ?>" size='20' />
@@ -276,13 +271,12 @@
277272 <?php $this->msgWiki('prefs-help-realname'); ?>
278273 </div>
279274 </td>
280 - <td></td>
281275 <?php } ?>
282276 <?php if( $this->data['usereason'] ) { ?>
283277 </tr>
284278 <tr>
285279 <td class="mw-label"><label for='wpReason'><?php $this->msg('createaccountreason') ?></label></td>
286 - <td class="mw-input" colspan="2">
 280+ <td class="mw-input">
287281 <input type='text' class='loginText' name="wpReason" id="wpReason"
288282 tabindex="7"
289283 value="<?php $this->text('reason') ?>" size='20' />
@@ -292,7 +286,7 @@
293287 <?php if( $this->data['canremember'] ) { ?>
294288 <tr>
295289 <td></td>
296 - <td class="mw-input" colspan="2">
 290+ <td class="mw-input">
297291 <?php
298292 global $wgCookieExpiration, $wgLang;
299293 echo Xml::checkLabel(
@@ -320,7 +314,7 @@
321315 ?><td><?php
322316 }
323317 ?></td>
324 - <td class="mw-input" colspan="2">
 318+ <td class="mw-input">
325319 <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
326320 echo htmlspecialchars( $inputItem['name'] ); ?>"
327321 tabindex="<?php echo $tabIndex++; ?>"
@@ -355,7 +349,7 @@
356350 ?>
357351 <tr>
358352 <td></td>
359 - <td class="mw-submit" colspan="2">
 353+ <td class="mw-submit">
360354 <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
361355 tabindex="<?php echo $tabIndex++; ?>"
362356 value="<?php $this->msg('createaccount') ?>" />

Follow-up revisions

RevisionCommit summaryAuthorDate
r81450* Rebuild messages files after removal of messages in r81445 and r81448....siebrand14:51, 3 February 2011
r86157Merge r81445 from 1.17: revert r70520 (js password complexity checker)demon23:38, 15 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70520JavaScript-based password complexity checker on account creation and password...maxsem19:16, 5 August 2010

Status & tagging log