diff --git src/wp-admin/js/password-strength-meter.js src/wp-admin/js/password-strength-meter.js
index efd26bbc5a..3a8c9da9f0 100644
|
|
|
window.wp = window.wp || {}; |
| 3 | 3 | |
| 4 | 4 | var passwordStrength; |
| 5 | 5 | (function($){ |
| | 6 | |
| | 7 | /** |
| | 8 | * The Password Strength object. |
| | 9 | * |
| | 10 | * Contains functions to determine the password strength. |
| | 11 | * |
| | 12 | * @since 3.7.0 |
| | 13 | * |
| | 14 | * @namespace |
| | 15 | */ |
| 6 | 16 | wp.passwordStrength = { |
| 7 | 17 | /** |
| 8 | | * Determine the strength of a given password |
| | 18 | * Determines the strength of a given password. |
| | 19 | * |
| | 20 | * @since 3.7.0 |
| | 21 | * |
| | 22 | * @param {string} password1 The password. |
| | 23 | * @param {Array} blacklist An array of words that will lower the entropy of the password. |
| | 24 | * @param {string} password2 The confirmed password. |
| 9 | 25 | * |
| 10 | | * @param string password1 The password |
| 11 | | * @param array blacklist An array of words that will lower the entropy of the password |
| 12 | | * @param string password2 The confirmed password |
| | 26 | * @returns {number} The password strength score. |
| 13 | 27 | */ |
| 14 | 28 | meter : function( password1, blacklist, password2 ) { |
| 15 | 29 | if ( ! $.isArray( blacklist ) ) |
| … |
… |
var passwordStrength; |
| 28 | 42 | }, |
| 29 | 43 | |
| 30 | 44 | /** |
| 31 | | * Builds an array of data that should be penalized, because it would lower the entropy of a password if it were used |
| | 45 | * Builds an array of data that should be penalized. |
| | 46 | * |
| | 47 | * Certain words need to be penalized because it would lower the entropy of a password if they were used. |
| | 48 | * The blacklist is based on user input fields such as username, first name, email etc. |
| | 49 | * |
| | 50 | * @since 3.7.0 |
| 32 | 51 | * |
| 33 | | * @return array The array of data to be blacklisted |
| | 52 | * @returns {Array} The array of data to be blacklisted. |
| 34 | 53 | */ |
| 35 | 54 | userInputBlacklist : function() { |
| 36 | 55 | var i, userInputFieldsLength, rawValuesLength, currentField, |
| … |
… |
var passwordStrength; |
| 38 | 57 | blacklist = [], |
| 39 | 58 | userInputFields = [ 'user_login', 'first_name', 'last_name', 'nickname', 'display_name', 'email', 'url', 'description', 'weblog_title', 'admin_email' ]; |
| 40 | 59 | |
| 41 | | // Collect all the strings we want to blacklist |
| | 60 | // Collect all the strings we want to blacklist. |
| 42 | 61 | rawValues.push( document.title ); |
| 43 | 62 | rawValues.push( document.URL ); |
| 44 | 63 | |
| … |
… |
var passwordStrength; |
| 54 | 73 | rawValues.push( currentField.val() ); |
| 55 | 74 | } |
| 56 | 75 | |
| 57 | | // Strip out non-alphanumeric characters and convert each word to an individual entry |
| | 76 | // Strip out non-alphanumeric characters and convert each word to an individual entry. |
| 58 | 77 | rawValuesLength = rawValues.length; |
| 59 | 78 | for ( i = 0; i < rawValuesLength; i++ ) { |
| 60 | 79 | if ( rawValues[ i ] ) { |
| … |
… |
var passwordStrength; |
| 62 | 81 | } |
| 63 | 82 | } |
| 64 | 83 | |
| 65 | | // Remove empty values, short words, and duplicates. Short words are likely to cause many false positives. |
| | 84 | // Remove empty values, short words and duplicates. Short words are likely to cause many false positives. |
| 66 | 85 | blacklist = $.grep( blacklist, function( value, key ) { |
| 67 | 86 | if ( '' === value || 4 > value.length ) { |
| 68 | 87 | return false; |
| … |
… |
var passwordStrength; |
| 75 | 94 | } |
| 76 | 95 | }; |
| 77 | 96 | |
| 78 | | // Back-compat. |
| | 97 | // Backward compatibility. |
| 79 | 98 | passwordStrength = wp.passwordStrength.meter; |
| 80 | 99 | })(jQuery); |