WordPress.org

Make WordPress Core

Ticket #42766: 42766.diff

File 42766.diff, 1010 bytes (added by 1naveengiri, 4 years ago)

Good Catch @ronakganatra Adding fix patch for it.

  • wp-admin/includes/user.php

    diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php
    index 269d64fb26..7729d5220d 100644
    a b function edit_user( $user_id = 0 ) { 
    4545
    4646        $pass1 = $pass2 = '';
    4747        if ( isset( $_POST['pass1'] ) ) {
    48                 $pass1 = $_POST['pass1'];
     48                $pass1 = trim( $_POST['pass1'] );
    4949        }
    5050        if ( isset( $_POST['pass2'] ) ) {
    51                 $pass2 = $_POST['pass2'];
     51                $pass2 = trim( $_POST['pass2'] );
    5252        }
    5353
    5454        if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) {
    function edit_user( $user_id = 0 ) { 
    156156        // Check for blank password when adding a user.
    157157        if ( ! $update && empty( $pass1 ) ) {
    158158                $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter a password.' ), array( 'form-field' => 'pass1' ) );
     159        } elseif ( $update && empty( $pass1 ) ) {
     160                $errors->add( 'pass', __( '<strong>ERROR</strong>: The password field is empty.' ), array( 'form-field' => 'pass1' ) );
    159161        }
    160162
    161163        // Check for "\" in password.