Making WordPress.org

Changeset 10288


Ignore:
Timestamp:
09/26/2020 01:46:31 AM (5 years ago)
Author:
dd32
Message:

Login: Don't allow usernames with trailing spaces or other whitespace around it.

A handful of new registrations included a space trailing their username which caused the confirmation emails to include invalid activation links.

See https://wordpress.slack.com/archives/C08M59V3P/p1601053672001300

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-registration.php

    r10029 r10288  
    4949function wporg_login_create_pending_user( $user_login, $user_email, $user_mailinglist = false  ) {
    5050    global $wpdb, $wp_hasher;
     51
     52    // Remove any whitespace which might have accidentally been added.
     53    $user_login = trim( $user_login );
     54    $user_email = trim( $user_email );
    5155
    5256    // Allow for w.org plugins to block registrations based on spam checks, etc.
     
    132136    $body .= sprintf( __( 'Your username is: %s', 'wporg' ), $user_login ) . "\n";
    133137    $body .= __( 'You can create a password at the following URL:', 'wporg' ) . "\n";
    134     $body .= home_url( "/register/create/{$user_login}/{$activation_key}/" );
     138    $body .= home_url( '/register/create/' . urlencode( $user_login ) . '/' . urlencode( $activation_key ) . '/' );
    135139    $body .= "\n\n";
    136140    $body .= __( '-- The WordPress.org Team', 'wporg' );
     
    204208
    205209    // Insert user, no password tho.
    206     $user_login = $pending_user['user_login'];
    207     $user_email = $pending_user['user_email'];
     210    $user_login = trim( $pending_user['user_login'] );
     211    $user_email = trim( $pending_user['user_email'] );
    208212    $user_mailinglist = !empty( $pending_user['meta']['user_mailinglist'] ) && $pending_user['meta']['user_mailinglist'];
    209213
     
    279283    foreach ( $fields as $field ) {
    280284        if ( isset( $_POST['user_fields'][ $field ] ) ) {
    281             $value = sanitize_text_field( wp_unslash( $_POST['user_fields'][ $field ] ) );
     285            $value = trim( sanitize_text_field( wp_unslash( $_POST['user_fields'][ $field ] ) ) );
    282286            if ( 'url' == $field ) {
    283287                if ( $pending_user ) {
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/register.php

    r10206 r10288  
    66 */
    77
    8 $user_login = isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : '';
     8$user_login = isset( $_POST['user_login'] ) ? trim( wp_unslash( $_POST['user_login'] ) ) : '';
    99if ( ! $user_login && !empty( WP_WPOrg_SSO::$matched_route_params['user'] ) ) {
    10     $user_login = WP_WPOrg_SSO::$matched_route_params['user'];
     10    $user_login = trim( WP_WPOrg_SSO::$matched_route_params['user'] );
    1111}
    12 $user_email = isset( $_POST['user_email'] ) ? wp_unslash( $_POST['user_email'] ) : '';
     12$user_email = isset( $_POST['user_email'] ) ? trim( wp_unslash( $_POST['user_email'] ) ) : '';
    1313$user_mailinglist = isset( $_POST['user_mailinglist'] ) && 'true' == $_POST['user_mailinglist'];
    1414
Note: See TracChangeset for help on using the changeset viewer.