Make WordPress Core

Ticket #35500: 35500.2.diff

File 35500.2.diff, 829 bytes (added by costdev, 3 years ago)

Patch refreshed after testing by @peterwilsoncc. Compares $_POST['pass1'] to trim( $_POST['pass2'] ).

  • src/wp-login.php

    diff --git a/src/wp-login.php b/src/wp-login.php
    index 45c207d81a..781f8b246f 100644
    a b switch ( $action ) { 
    904904
    905905                $errors = new WP_Error();
    906906
    907                 if ( isset( $_POST['pass1'] ) && $_POST['pass1'] !== $_POST['pass2'] ) {
     907                // Check if password is one or all empty spaces.
     908                if ( ! empty( $_POST['pass1'] ) ) {
     909                        $_POST['pass1'] = trim( $_POST['pass1'] );
     910
     911                        if ( empty( $_POST['pass1'] ) ) {
     912                                $errors->add( 'password_reset_empty_space', __( 'The password cannot be a space or all spaces.' ) );
     913                        }
     914                }
     915
     916                // Check if password fields do not match.
     917                if ( ! empty( $_POST['pass1'] ) && $_POST['pass1'] !== trim( $_POST['pass2'] ) ) {
    908918                        $errors->add( 'password_reset_mismatch', __( '<strong>Error</strong>: The passwords do not match.' ) );
    909919                }
    910920