[wp-trac] [WordPress Trac] #54987: Check if 'user_nicename' is not too long after the 'pre_user_nicename' filter
WordPress Trac
noreply at wordpress.org
Sat Jan 29 15:49:53 UTC 2022
#54987: Check if 'user_nicename' is not too long after the 'pre_user_nicename'
filter
--------------------------------------+---------------------
Reporter: SergeyBiryukov | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.0
Component: Users | Version:
Severity: normal | Resolution:
Keywords: good-first-bug has-patch | Focuses:
--------------------------------------+---------------------
Comment (by muhammadfaizanhaidar):
@SergeyBiryukov did not notice it already had a patch but I have removed
size check from earlier location and added a more strict check after the
'pre_user_nicename' filter
Following added.
{{{#!php
<?php
// Remove any non-printable chars from the user_nicename string to see if
we have ended up with an empty username.
$user_nicename = trim( $user_nicename );
// user_nicename must be between 0 and 50 characters.
if ( empty( $user_nicename ) ) {
return new WP_Error( 'empty_user_nicename', __( 'Cannot
create a user with an empty nicename.' ) );
} elseif ( mb_strlen( $user_nicename ) > 50 ) {
return new WP_Error( 'user_nicename_too_long', __(
'Nicename may not be longer than 50 characters.' ) );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54987#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list