Skip to content

Commit

Permalink
fix(ras): prevent email address exposure via user login (#3139)
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek authored and dkoo committed Jun 11, 2024
1 parent 6ab9ec6 commit a1b08c3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -1727,9 +1727,7 @@ public static function canonize_user_data( $user_data = [] ) {
return $user_data;
}

$user_login = str_replace( '+', '_', \sanitize_user( $user_data['user_email'], true ) ); // Matches the email address, but replace + with _ to allow for Gmail aliases.
$random_password = \wp_generate_password();
$user_nicename = self::generate_user_nicename( ! empty( $user_data['display_name'] ) ? $user_data['display_name'] : $user_data['user_email'] );
$user_nicename = self::generate_user_nicename( ! empty( $user_data['display_name'] ) ? $user_data['display_name'] : $user_data['user_email'] );

// If we don't have a display name, make it match the nicename.
if ( empty( $user_data['display_name'] ) ) {
Expand All @@ -1739,9 +1737,10 @@ public static function canonize_user_data( $user_data = [] ) {
$user_data = array_merge(
$user_data,
[
'user_login' => $user_login,
'user_login' => $user_nicename,
'user_nicename' => $user_nicename,
'user_pass' => $random_password,
'display_name' => $user_nicename,
'user_pass' => \wp_generate_password(),
]
);

Expand Down

0 comments on commit a1b08c3

Please sign in to comment.