* @private
*/
function getUserSig( &$user ) {
+ global $wgMaxSigChars;
+
$username = $user->getName();
$nickname = $user->getOption( 'nickname' );
$nickname = $nickname === '' ? $username : $nickname;
-
- if( $user->getBoolOption( 'fancysig' ) !== false ) {
+
+ if( strlen( $nickname ) > $wgMaxSigChars ) {
+ $nickname = $username;
+ wfDebug( __METHOD__ . ": $username has overlong signature.\n" );
+ } elseif( $user->getBoolOption( 'fancysig' ) !== false ) {
# Sig. might contain markup; validate this
if( $this->validateSig( $nickname ) !== false ) {
# Validated; clean up (if needed) and return it
}
# Validate the signature and clean it up as needed
- if( $this->mToggles['fancysig'] ) {
+ global $wgMaxSigChars;
+ if( strlen( $this->mNick ) > $wgMaxSigChars ) {
+ global $wgLang;
+ $this->mainPrefsForm( 'error',
+ wfMsg( 'badsiglength', $wgLang->formatNum( $wgMaxSigChars ) ) );
+ return;
+ } elseif( $this->mToggles['fancysig'] ) {
if( Parser::validateSig( $this->mNick ) !== false ) {
$this->mNick = $wgParser->cleanSig( $this->mNick );
} else {
);
}
- global $wgParser;
- if( !empty( $this->mToggles['fancysig'] ) &&
+ global $wgParser, $wgMaxSigChars;
+ if( strlen( $this->mNick ) > $wgMaxSigChars ) {
+ $invalidSig = $this->tableRow(
+ ' ',
+ Xml::element( 'span', array( 'class' => 'error' ),
+ wfMsg( 'badsiglength', $wgLang->formatNum( $wgMaxSigChars ) ) )
+ );
+ } elseif( !empty( $this->mToggles['fancysig'] ) &&
false === $wgParser->validateSig( $this->mNick ) ) {
$invalidSig = $this->tableRow(
' ',
$wgOut->addHTML(
$this->tableRow(
Xml::label( wfMsg( 'yournick' ), 'wpNick' ),
- Xml::input( 'wpNick', 25, $this->mNick, array( 'id' => 'wpNick' ) )
+ Xml::input( 'wpNick', 25, $this->mNick,
+ array(
+ 'id' => 'wpNick',
+ // Note: $wgMaxSigChars is currently enforced in UTF-8 bytes,
+ // but 'maxlength' attribute is enforced in characters.
+ // It's still possible to put in an overlong string
+ // 'legitimately' by typing non-ASCII chars.
+ 'maxlength' => $wgMaxSigChars ) )
) .
$invalidSig .
$this->tableRow( ' ', $this->getToggle( 'fancysig' ) )
'yourvariant' => 'Variant',
'yournick' => 'Nickname:',
'badsig' => 'Invalid raw signature; check HTML tags.',
+'badsiglength' => 'Nickname too long; must be under $1 characters.',
'email' => 'E-mail',
'prefs-help-realname' => 'Real name is optional and if you choose to provide it this will be used for giving you attribution for your work.',
'loginerror' => 'Login error',