[wp-trac] [WordPress Trac] #44672: REST-API: invalid email on lowercase/uppercase change

WordPress Trac noreply at wordpress.org
Mon Jul 30 15:13:04 UTC 2018


#44672: REST-API: invalid email on lowercase/uppercase change
--------------------------+-----------------------------
 Reporter:  fuchsws       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  4.9.7
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When changing an email adresse from lower to uppercase (and vice versa)
 the error "rest_user_invalid_email" is thrown. This is wrong and it should
 work as in edit_user().

 Examples:

 [REST-API] change email from "UserName at domain.com" to
 "username at domain.com" results in ERROR

 [WP-admin] change email from "UserName at domain.com" to
 "username at domain.com" results in SUCCESS



 Both functions use different types of comparisons, while edit_user() is
 correct and REST-API wrong:


 WP_REST_Users_Controller > update_item():

 {{{#!php
 <?php
 if ( email_exists( $request['email'] ) && $request['email'] !==
 $user->user_email )
 }}}


 wp-admin/includes/user.php > edit_user()

 {{{#!php
 <?php
 $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) );

 [...]

 elseif ( ( $owner_id = email_exists($user->user_email) ) && ( !$update ||
 ( $owner_id != $user->ID ) ) )
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44672>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list