r22960 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22959‎ | r22960 | r22961 >
Date:16:28, 13 June 2007
Author:brion
Status:old
Tags:
Comment:
* (bug 8458) Limit custom signature length to $wgMaxSigChars bytes
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/includes/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -3803,11 +3803,16 @@
38043804 * @private
38053805 */
38063806 function getUserSig( &$user ) {
 3807+ global $wgMaxSigChars;
 3808+
38073809 $username = $user->getName();
38083810 $nickname = $user->getOption( 'nickname' );
38093811 $nickname = $nickname === '' ? $username : $nickname;
3810 -
3811 - if( $user->getBoolOption( 'fancysig' ) !== false ) {
 3812+
 3813+ if( strlen( $nickname ) > $wgMaxSigChars ) {
 3814+ $nickname = $username;
 3815+ wfDebug( __METHOD__ . ": $username has overlong signature.\n" );
 3816+ } elseif( $user->getBoolOption( 'fancysig' ) !== false ) {
38123817 # Sig. might contain markup; validate this
38133818 if( $this->validateSig( $nickname ) !== false ) {
38143819 # Validated; clean up (if needed) and return it
Index: trunk/phase3/includes/SpecialPreferences.php
@@ -241,7 +241,13 @@
242242 }
243243
244244 # Validate the signature and clean it up as needed
245 - if( $this->mToggles['fancysig'] ) {
 245+ global $wgMaxSigChars;
 246+ if( strlen( $this->mNick ) > $wgMaxSigChars ) {
 247+ global $wgLang;
 248+ $this->mainPrefsForm( 'error',
 249+ wfMsg( 'badsiglength', $wgLang->formatNum( $wgMaxSigChars ) ) );
 250+ return;
 251+ } elseif( $this->mToggles['fancysig'] ) {
246252 if( Parser::validateSig( $this->mNick ) !== false ) {
247253 $this->mNick = $wgParser->cleanSig( $this->mNick );
248254 } else {
@@ -603,8 +609,14 @@
604610 );
605611 }
606612
607 - global $wgParser;
608 - if( !empty( $this->mToggles['fancysig'] ) &&
 613+ global $wgParser, $wgMaxSigChars;
 614+ if( strlen( $this->mNick ) > $wgMaxSigChars ) {
 615+ $invalidSig = $this->tableRow(
 616+ ' ',
 617+ Xml::element( 'span', array( 'class' => 'error' ),
 618+ wfMsg( 'badsiglength', $wgLang->formatNum( $wgMaxSigChars ) ) )
 619+ );
 620+ } elseif( !empty( $this->mToggles['fancysig'] ) &&
609621 false === $wgParser->validateSig( $this->mNick ) ) {
610622 $invalidSig = $this->tableRow(
611623 ' ',
@@ -617,7 +629,14 @@
618630 $wgOut->addHTML(
619631 $this->tableRow(
620632 Xml::label( wfMsg( 'yournick' ), 'wpNick' ),
621 - Xml::input( 'wpNick', 25, $this->mNick, array( 'id' => 'wpNick' ) )
 633+ Xml::input( 'wpNick', 25, $this->mNick,
 634+ array(
 635+ 'id' => 'wpNick',
 636+ // Note: $wgMaxSigChars is currently enforced in UTF-8 bytes,
 637+ // but 'maxlength' attribute is enforced in characters.
 638+ // It's still possible to put in an overlong string
 639+ // 'legitimately' by typing non-ASCII chars.
 640+ 'maxlength' => $wgMaxSigChars ) )
622641 ) .
623642 $invalidSig .
624643 $this->tableRow( ' ', $this->getToggle( 'fancysig' ) )
Index: trunk/phase3/includes/DefaultSettings.php
@@ -857,6 +857,7 @@
858858
859859 $wgShowIPinHeader = true; # For non-logged in users
860860 $wgMaxNameChars = 255; # Maximum number of bytes in username
 861+$wgMaxSigChars = 255; # Maximum number of bytes in signature
861862 $wgMaxArticleSize = 2048; # Maximum article size in kilobytes
862863
863864 $wgExtraSubtitle = '';
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -830,6 +830,7 @@
831831 'yourvariant' => 'Variant',
832832 'yournick' => 'Nickname:',
833833 'badsig' => 'Invalid raw signature; check HTML tags.',
 834+'badsiglength' => 'Nickname too long; must be under $1 characters.',
834835 'email' => 'E-mail',
835836 '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.',
836837 'loginerror' => 'Login error',
Index: trunk/phase3/RELEASE-NOTES
@@ -82,7 +82,9 @@
8383 Common.css and MediaWiki:Monobook.css.
8484 * (bug 8869) Introduce Special:Uncategorizedtemplates
8585 * (bug 8734) Different log message when article protection level is changed
 86+* (bug 8458) Limit custom signature length to $wgMaxSigChars bytes
8687
 88+
8789 == Bugfixes since 1.10 ==
8890
8991 * (bug 9712) Use Arabic comma in date/time formats for Arabic and Farsi

Follow-up revisions

RevisionCommit summaryAuthorDate
r22967Merged revisions 22935-22966 via svnmerge from...david18:35, 13 June 2007

Status & tagging log