Edit File by line
/home/barbar84/www/wp-admin/js
File: password-strength-meter.js
/**
[0] Fix | Delete
* @output wp-admin/js/password-strength-meter.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
/* global zxcvbn */
[4] Fix | Delete
window.wp = window.wp || {};
[5] Fix | Delete
[6] Fix | Delete
(function($){
[7] Fix | Delete
var __ = wp.i18n.__,
[8] Fix | Delete
sprintf = wp.i18n.sprintf;
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Contains functions to determine the password strength.
[12] Fix | Delete
*
[13] Fix | Delete
* @since 3.7.0
[14] Fix | Delete
*
[15] Fix | Delete
* @namespace
[16] Fix | Delete
*/
[17] Fix | Delete
wp.passwordStrength = {
[18] Fix | Delete
/**
[19] Fix | Delete
* Determines the strength of a given password.
[20] Fix | Delete
*
[21] Fix | Delete
* Compares first password to the password confirmation.
[22] Fix | Delete
*
[23] Fix | Delete
* @since 3.7.0
[24] Fix | Delete
*
[25] Fix | Delete
* @param {string} password1 The subject password.
[26] Fix | Delete
* @param {Array} disallowedList An array of words that will lower the entropy of
[27] Fix | Delete
* the password.
[28] Fix | Delete
* @param {string} password2 The password confirmation.
[29] Fix | Delete
*
[30] Fix | Delete
* @return {number} The password strength score.
[31] Fix | Delete
*/
[32] Fix | Delete
meter : function( password1, disallowedList, password2 ) {
[33] Fix | Delete
if ( ! Array.isArray( disallowedList ) )
[34] Fix | Delete
disallowedList = [ disallowedList.toString() ];
[35] Fix | Delete
[36] Fix | Delete
if (password1 != password2 && password2 && password2.length > 0)
[37] Fix | Delete
return 5;
[38] Fix | Delete
[39] Fix | Delete
if ( 'undefined' === typeof window.zxcvbn ) {
[40] Fix | Delete
// Password strength unknown.
[41] Fix | Delete
return -1;
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
var result = zxcvbn( password1, disallowedList );
[45] Fix | Delete
return result.score;
[46] Fix | Delete
},
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Builds an array of words that should be penalized.
[50] Fix | Delete
*
[51] Fix | Delete
* Certain words need to be penalized because it would lower the entropy of a
[52] Fix | Delete
* password if they were used. The disallowedList is based on user input fields such
[53] Fix | Delete
* as username, first name, email etc.
[54] Fix | Delete
*
[55] Fix | Delete
* @since 3.7.0
[56] Fix | Delete
* @deprecated 5.5.0 Use {@see 'userInputDisallowedList()'} instead.
[57] Fix | Delete
*
[58] Fix | Delete
* @return {string[]} The array of words to be disallowed.
[59] Fix | Delete
*/
[60] Fix | Delete
userInputBlacklist : function() {
[61] Fix | Delete
window.console.log(
[62] Fix | Delete
sprintf(
[63] Fix | Delete
/* translators: 1: Deprecated function name, 2: Version number, 3: Alternative function name. */
[64] Fix | Delete
__( '%1$s is deprecated since version %2$s! Use %3$s instead. Please consider writing more inclusive code.' ),
[65] Fix | Delete
'wp.passwordStrength.userInputBlacklist()',
[66] Fix | Delete
'5.5.0',
[67] Fix | Delete
'wp.passwordStrength.userInputDisallowedList()'
[68] Fix | Delete
)
[69] Fix | Delete
);
[70] Fix | Delete
[71] Fix | Delete
return wp.passwordStrength.userInputDisallowedList();
[72] Fix | Delete
},
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Builds an array of words that should be penalized.
[76] Fix | Delete
*
[77] Fix | Delete
* Certain words need to be penalized because it would lower the entropy of a
[78] Fix | Delete
* password if they were used. The disallowed list is based on user input fields such
[79] Fix | Delete
* as username, first name, email etc.
[80] Fix | Delete
*
[81] Fix | Delete
* @since 5.5.0
[82] Fix | Delete
*
[83] Fix | Delete
* @return {string[]} The array of words to be disallowed.
[84] Fix | Delete
*/
[85] Fix | Delete
userInputDisallowedList : function() {
[86] Fix | Delete
var i, userInputFieldsLength, rawValuesLength, currentField,
[87] Fix | Delete
rawValues = [],
[88] Fix | Delete
disallowedList = [],
[89] Fix | Delete
userInputFields = [ 'user_login', 'first_name', 'last_name', 'nickname', 'display_name', 'email', 'url', 'description', 'weblog_title', 'admin_email' ];
[90] Fix | Delete
[91] Fix | Delete
// Collect all the strings we want to disallow.
[92] Fix | Delete
rawValues.push( document.title );
[93] Fix | Delete
rawValues.push( document.URL );
[94] Fix | Delete
[95] Fix | Delete
userInputFieldsLength = userInputFields.length;
[96] Fix | Delete
for ( i = 0; i < userInputFieldsLength; i++ ) {
[97] Fix | Delete
currentField = $( '#' + userInputFields[ i ] );
[98] Fix | Delete
[99] Fix | Delete
if ( 0 === currentField.length ) {
[100] Fix | Delete
continue;
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
rawValues.push( currentField[0].defaultValue );
[104] Fix | Delete
rawValues.push( currentField.val() );
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
/*
[108] Fix | Delete
* Strip out non-alphanumeric characters and convert each word to an
[109] Fix | Delete
* individual entry.
[110] Fix | Delete
*/
[111] Fix | Delete
rawValuesLength = rawValues.length;
[112] Fix | Delete
for ( i = 0; i < rawValuesLength; i++ ) {
[113] Fix | Delete
if ( rawValues[ i ] ) {
[114] Fix | Delete
disallowedList = disallowedList.concat( rawValues[ i ].replace( /\W/g, ' ' ).split( ' ' ) );
[115] Fix | Delete
}
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
/*
[119] Fix | Delete
* Remove empty values, short words and duplicates. Short words are likely to
[120] Fix | Delete
* cause many false positives.
[121] Fix | Delete
*/
[122] Fix | Delete
disallowedList = $.grep( disallowedList, function( value, key ) {
[123] Fix | Delete
if ( '' === value || 4 > value.length ) {
[124] Fix | Delete
return false;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
return $.inArray( value, disallowedList ) === key;
[128] Fix | Delete
});
[129] Fix | Delete
[130] Fix | Delete
return disallowedList;
[131] Fix | Delete
}
[132] Fix | Delete
};
[133] Fix | Delete
[134] Fix | Delete
// Backward compatibility.
[135] Fix | Delete
[136] Fix | Delete
/**
[137] Fix | Delete
* Password strength meter function.
[138] Fix | Delete
*
[139] Fix | Delete
* @since 2.5.0
[140] Fix | Delete
* @deprecated 3.7.0 Use wp.passwordStrength.meter instead.
[141] Fix | Delete
*
[142] Fix | Delete
* @global
[143] Fix | Delete
*
[144] Fix | Delete
* @type {wp.passwordStrength.meter}
[145] Fix | Delete
*/
[146] Fix | Delete
window.passwordStrength = wp.passwordStrength.meter;
[147] Fix | Delete
})(jQuery);
[148] Fix | Delete
[149] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function