Make WordPress Core

Ticket #43066: password-strength-meter.diff

File password-strength-meter.diff, 3.2 KB (added by jjcomack, 7 years ago)
  • src/wp-admin/js/password-strength-meter.js

    diff --git src/wp-admin/js/password-strength-meter.js src/wp-admin/js/password-strength-meter.js
    index efd26bbc5a..fa226dcc46 100644
    window.wp = window.wp || {}; 
    33
    44var passwordStrength;
    55(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         */
    616        wp.passwordStrength = {
    717                /**
    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.
    925                 *
    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.
    1327                 */
    1428                meter : function( password1, blacklist, password2 ) {
    1529                        if ( ! $.isArray( blacklist ) )
    var passwordStrength; 
    2842                },
    2943
    3044                /**
    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
    3251                 *
    33                  * @return array The array of data to be blacklisted
     52                 * @returns {Array} The array of data to be blacklisted.
    3453                 */
    3554                userInputBlacklist : function() {
    3655                        var i, userInputFieldsLength, rawValuesLength, currentField,
    var passwordStrength; 
    3857                                blacklist       = [],
    3958                                userInputFields = [ 'user_login', 'first_name', 'last_name', 'nickname', 'display_name', 'email', 'url', 'description', 'weblog_title', 'admin_email' ];
    4059
    41                         // Collect all the strings we want to blacklist
     60                        // Collect all the strings we want to blacklist.
    4261                        rawValues.push( document.title );
    4362                        rawValues.push( document.URL );
    4463
    var passwordStrength; 
    5473                                rawValues.push( currentField.val() );
    5574                        }
    5675
    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.
    5877                        rawValuesLength = rawValues.length;
    5978                        for ( i = 0; i < rawValuesLength; i++ ) {
    6079                                if ( rawValues[ i ] ) {
    var passwordStrength; 
    6281                                }
    6382                        }
    6483
    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.
    6685                        blacklist = $.grep( blacklist, function( value, key ) {
    6786                                if ( '' === value || 4 > value.length ) {
    6887                                        return false;
    var passwordStrength; 
    7594                }
    7695        };
    7796
    78         // Back-compat.
     97        // Backwards compatability.
    7998        passwordStrength = wp.passwordStrength.meter;
    8099})(jQuery);