Login and Registration: Disable spellcheck for password fields.

This changeset adds `spellcheck="false"` attribute to various password fields.

The spellcheck global attribute defines whether the element may be checked for spelling errors. The `false` value indicates that the element should not be checked for spelling errors, which is relevant for a password field.

Furthermore, and as per MDN specs, using spellchecking can have consequences for users' security and privacy. The specification does not regulate how spellchecking is done and the content of the element may be sent to a third party for spellchecking results. Thus, it is recommended to set `spellcheck` attribute to `false` for elements that can contain sensitive information. Which is the case for password fields.

Props dziudek, audrasjb, gainesm, fosuahmed.
Fixes #56763.

Built from https://develop.svn.wordpress.org/trunk@55094


git-svn-id: http://core.svn.wordpress.org/trunk@54627 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2023-01-19 08:53:13 +00:00
parent 1a21c14d85
commit 0f28fc7aed
8 changed files with 13 additions and 13 deletions

View File

@ -2390,7 +2390,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
<div class="ftp-password"> <div class="ftp-password">
<label for="password"> <label for="password">
<span class="field-title"><?php echo $label_pass; ?></span> <span class="field-title"><?php echo $label_pass; ?></span>
<input name="password" type="password" id="password" value="<?php echo $password_value; ?>"<?php disabled( defined( 'FTP_PASS' ) ); ?> /> <input name="password" type="password" id="password" value="<?php echo $password_value; ?>"<?php disabled( defined( 'FTP_PASS' ) ); ?> spellcheck="false" />
<?php <?php
if ( ! defined( 'FTP_PASS' ) ) { if ( ! defined( 'FTP_PASS' ) ) {
_e( 'This password will not be stored on the server.' ); _e( 'This password will not be stored on the server.' );

View File

@ -140,7 +140,7 @@ function display_setup_form( $error = null ) {
<td> <td>
<div class="wp-pwd"> <div class="wp-pwd">
<?php $initial_password = isset( $_POST['admin_password'] ) ? stripslashes( $_POST['admin_password'] ) : wp_generate_password( 18 ); ?> <?php $initial_password = isset( $_POST['admin_password'] ) ? stripslashes( $_POST['admin_password'] ) : wp_generate_password( 18 ); ?>
<input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="new-password" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" /> <input type="password" name="admin_password" id="pass1" class="regular-text" spellcheck="false" autocomplete="new-password" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
<button type="button" class="button wp-hide-pw hide-if-no-js" data-start-masked="<?php echo (int) isset( $_POST['admin_password'] ); ?>" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> <button type="button" class="button wp-hide-pw hide-if-no-js" data-start-masked="<?php echo (int) isset( $_POST['admin_password'] ); ?>" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
<span class="dashicons dashicons-hidden"></span> <span class="dashicons dashicons-hidden"></span>
<span class="text"><?php _e( 'Hide' ); ?></span> <span class="text"><?php _e( 'Hide' ); ?></span>
@ -160,7 +160,7 @@ function display_setup_form( $error = null ) {
</label> </label>
</th> </th>
<td> <td>
<input name="admin_password2" type="password" id="pass2" autocomplete="new-password" /> <input name="admin_password2" type="password" id="pass2" autocomplete="new-password" spellcheck="false" />
</td> </td>
</tr> </tr>
<tr class="pw-weak"> <tr class="pw-weak">

View File

@ -638,7 +638,7 @@ switch ( $action ) {
<button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button> <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button>
<div class="wp-pwd hide-if-js"> <div class="wp-pwd hide-if-js">
<span class="password-input-wrapper"> <span class="password-input-wrapper">
<input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="new-password" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" /> <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="new-password" spellcheck="false" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" />
</span> </span>
<button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
<span class="dashicons dashicons-hidden" aria-hidden="true"></span> <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
@ -655,7 +655,7 @@ switch ( $action ) {
<tr class="user-pass2-wrap hide-if-js"> <tr class="user-pass2-wrap hide-if-js">
<th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th> <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
<td> <td>
<input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="new-password" aria-describedby="pass2-desc" /> <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="new-password" spellcheck="false" aria-describedby="pass2-desc" />
<?php if ( IS_PROFILE_PAGE ) : ?> <?php if ( IS_PROFILE_PAGE ) : ?>
<p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p> <p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p>
<?php else : ?> <?php else : ?>

View File

@ -571,7 +571,7 @@ if ( current_user_can( 'create_users' ) ) {
<div class="wp-pwd"> <div class="wp-pwd">
<?php $initial_password = wp_generate_password( 24 ); ?> <?php $initial_password = wp_generate_password( 24 ); ?>
<span class="password-input-wrapper"> <span class="password-input-wrapper">
<input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="new-password" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" /> <input type="password" name="pass1" id="pass1" class="regular-text" autocomplete="new-password" spellcheck="false" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
</span> </span>
<button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
<span class="dashicons dashicons-hidden" aria-hidden="true"></span> <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
@ -584,7 +584,7 @@ if ( current_user_can( 'create_users' ) ) {
<tr class="form-field form-required user-pass2-wrap hide-if-js"> <tr class="form-field form-required user-pass2-wrap hide-if-js">
<th scope="row"><label for="pass2"><?php _e( 'Repeat Password' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> <th scope="row"><label for="pass2"><?php _e( 'Repeat Password' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
<td> <td>
<input name="pass2" type="password" id="pass2" autocomplete="new-password" aria-describedby="pass2-desc" /> <input name="pass2" type="password" id="pass2" autocomplete="new-password" spellcheck="false" aria-describedby="pass2-desc" />
<p class="description" id="pass2-desc"><?php _e( 'Type the password again.' ); ?></p> <p class="description" id="pass2-desc"><?php _e( 'Type the password again.' ); ?></p>
</td> </td>
</tr> </tr>

View File

@ -595,7 +595,7 @@ function wp_login_form( $args = array() ) {
sprintf( sprintf(
'<p class="login-password"> '<p class="login-password">
<label for="%1$s">%2$s</label> <label for="%1$s">%2$s</label>
<input type="password" name="pwd" id="%1$s" autocomplete="current-password" class="input" value="" size="20" /> <input type="password" name="pwd" id="%1$s" autocomplete="current-password" spellcheck="false" class="input" value="" size="20" />
</p>', </p>',
esc_attr( $args['id_password'] ), esc_attr( $args['id_password'] ),
esc_html( $args['label_password'] ) esc_html( $args['label_password'] )

View File

@ -1752,7 +1752,7 @@ function get_the_password_form( $post = 0 ) {
$label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID ); $label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post"> $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
<p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p> <p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
<p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form> <p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" spellcheck="false" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
'; ';
/** /**

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.2-alpha-55093'; $wp_version = '6.2-alpha-55094';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -958,7 +958,7 @@ switch ( $action ) {
</p> </p>
<div class="wp-pwd"> <div class="wp-pwd">
<input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input password-input" size="24" value="" autocomplete="new-password" aria-describedby="pass-strength-result" /> <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input password-input" size="24" value="" autocomplete="new-password" spellcheck="false" aria-describedby="pass-strength-result" />
<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
<span class="dashicons dashicons-hidden" aria-hidden="true"></span> <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
@ -973,7 +973,7 @@ switch ( $action ) {
<p class="user-pass2-wrap"> <p class="user-pass2-wrap">
<label for="pass2"><?php _e( 'Confirm new password' ); ?></label> <label for="pass2"><?php _e( 'Confirm new password' ); ?></label>
<input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="new-password" /> <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="new-password" spellcheck="false" />
</p> </p>
<p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p> <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
@ -1423,7 +1423,7 @@ switch ( $action ) {
<div class="user-pass-wrap"> <div class="user-pass-wrap">
<label for="user_pass"><?php _e( 'Password' ); ?></label> <label for="user_pass"><?php _e( 'Password' ); ?></label>
<div class="wp-pwd"> <div class="wp-pwd">
<input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby; ?> class="input password-input" value="" size="20" autocomplete="current-password" /> <input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby; ?> class="input password-input" value="" size="20" autocomplete="current-password" spellcheck="false" />
<button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Show password' ); ?>"> <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Show password' ); ?>">
<span class="dashicons dashicons-visibility" aria-hidden="true"></span> <span class="dashicons dashicons-visibility" aria-hidden="true"></span>
</button> </button>