Make WordPress Core


Ignore:
Timestamp:
10/02/2014 06:53:24 PM (12 years ago)
Author:
boonebgorges
Message:

Always sanitize user_nicename in wp_insert_user().

Previously, a 'user_nicename' parameter passed into the function was
unsanitized. This could result in a mismatch between the sanitized nicename
generated automatically at user creation, resulting in broken author archive
permalinks.

Props joemcgill.

Fixes #29696.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user.php

    r29341 r29819  
    655655                $this->assertNotContains( 'key', $metas );
    656656        }
     657
     658        /**
     659         * @ticket 29696
     660         */
     661        public function test_wp_insert_user_should_sanitize_user_nicename_parameter() {
     662                $user = $this->factory->user->create_and_get();
     663
     664                $userdata = $user->to_array();
     665                $userdata['user_nicename'] = str_replace( '-', '.', $user->user_nicename );
     666                wp_insert_user( $userdata );
     667
     668                $updated_user = new WP_User( $user->ID );
     669
     670                $this->assertSame( $user->user_nicename, $updated_user->user_nicename );
     671        }
    657672}
Note: See TracChangeset for help on using the changeset viewer.