Making WordPress.org


Ignore:
Timestamp:
11/12/2025 04:43:43 AM (11 months ago)
Author:
dd32
Message:

Registration: Store a sanitised version of the email (no plus addressing) to ease searches for accounts by email address.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/class-user-registrations-list-table.php

    r14533 r14602  
    181181                        $search_term = wp_unslash( $_GET['s'] );
    182182                        $search_like = '%' . $wpdb->esc_like( $search_term ) . '%';
    183 
     183                       
    184184                        // Limit searches to where they're likely, for performance.
    185185                        if ( str_contains( $search_term, '@' ) ) {
     186                                $san_search_term = wporg_sanitize_email_for_search( $search_term );
     187                                $san_search_like = '%' . $wpdb->esc_like( $san_search_term ) . '%';
     188
    186189                                // If it looks like a full email, exact match.
    187190                                if ( preg_match( '/^.{3,}@.+[.].+$/', $search_term ) ) {
    188191                                        // Looks like an email, so just search the emails.
    189192                                        $where .= $wpdb->prepare(
    190                                                 "AND registrations.user_email = %s",
    191                                                 $search_term
     193                                                "AND ( registrations.user_email = %s OR registrations.user_email_san = %s )",
     194                                                $search_term,
     195                                                $san_search_term
    192196                                        );
    193197                                } else {
    194198                                        // Otherwise, a wildcard on the email.
    195199                                        $where .= $wpdb->prepare(
    196                                                 "AND registrations.user_email LIKE %s",
    197                                                 $search_like
     200                                                "AND ( registrations.user_email LIKE %s OR registrations.user_email_san LIKE %s )",
     201                                                $search_like,
     202                                                $san_search_like
    198203                                        );
    199204                                }
    … …  
    216221                                                registrations.user_login LIKE %s OR
    217222                                                registrations.user_email LIKE %s OR
     223                                                registrations.user_email_san LIKE %s OR
    218224                                                registrations.meta LIKE %s OR
    219225                                                description.meta_value LIKE %s
    220226                                        )",
    221                                         $search_like, $search_like, $search_like, $search_like
     227                                        $search_like, $search_like, $search_like, $search_like, $search_like
    222228                                );
    223229                        }
Note: See TracChangeset for help on using the changeset viewer.