r23389 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r23388 | r23389 (on ViewVC) | r23390 >
Date:15:02, 25 June 2007
Author:brion
Status:ok
Tags:
Comment:* (bug 10338) Enforce signature length limit in Unicode characters instead of bytes
Uses mb_strlen(), which we already have a fallback function for if mbstring extension isn't present.
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/Parser.php
===================================================================
--- trunk/phase3/includes/Parser.php	(revision 23388)
+++ trunk/phase3/includes/Parser.php	(revision 23389)
@@ -3812,7 +3812,7 @@
 		$nickname = $user->getOption( 'nickname' );
 		$nickname = $nickname === '' ? $username : $nickname;
 		
-		if( strlen( $nickname ) > $wgMaxSigChars ) {
+		if( mb_strlen( $nickname ) > $wgMaxSigChars ) {
 			$nickname = $username;
 			wfDebug( __METHOD__ . ": $username has overlong signature.\n" );
 		} elseif( $user->getBoolOption( 'fancysig' ) !== false ) {
Index: trunk/phase3/includes/SpecialPreferences.php
===================================================================
--- trunk/phase3/includes/SpecialPreferences.php	(revision 23388)
+++ trunk/phase3/includes/SpecialPreferences.php	(revision 23389)
@@ -242,7 +242,7 @@
 
 		# Validate the signature and clean it up as needed
 		global $wgMaxSigChars;
-		if( strlen( $this->mNick ) > $wgMaxSigChars ) {
+		if( mb_strlen( $this->mNick ) > $wgMaxSigChars ) {
 			global $wgLang;
 			$this->mainPrefsForm( 'error',
 				wfMsg( 'badsiglength', $wgLang->formatNum( $wgMaxSigChars ) ) );
@@ -610,7 +610,7 @@
 		}
 
 		global $wgParser, $wgMaxSigChars;
-		if( strlen( $this->mNick ) > $wgMaxSigChars ) {
+		if( mb_strlen( $this->mNick ) > $wgMaxSigChars ) {
 			$invalidSig = $this->tableRow(
 				' ',
 				Xml::element( 'span', array( 'class' => 'error' ),
@@ -632,10 +632,10 @@
 				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.
+						// Note: $wgMaxSigChars is enforced in Unicode characters,
+						// both on the backend and now in the browser.
+						// Badly-behaved requests may still try to submit
+						// an overlong string, however.
 						'maxlength' => $wgMaxSigChars ) )
 			) .
 			$invalidSig .
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 23388)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 23389)
@@ -857,7 +857,7 @@
 
 $wgShowIPinHeader	= true; # For non-logged in users
 $wgMaxNameChars		= 255;  # Maximum number of bytes in username
-$wgMaxSigChars      = 255;  # Maximum number of bytes in signature
+$wgMaxSigChars      = 255;  # Maximum number of Unicode characters in signature
 $wgMaxArticleSize	= 2048; # Maximum article size in kilobytes
 
 $wgExtraSubtitle	= '';
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 23388)
+++ trunk/phase3/RELEASE-NOTES	(revision 23389)
@@ -101,7 +101,9 @@
   enabled by default.
 * Added option to install to MyISAM
 * (bug 9250) Remove hardcoded minimum image name length of three characters
+* (bug 10338) Enforce signature length limit in Unicode characters instead of bytes
 
+
 == Bugfixes since 1.10 ==
 
 * (bug 9712) Use Arabic comma in date/time formats for Arabic and Farsi

Follow-up revisions

RevisionCommit summaryAuthorDate
r23407Merged revisions 23203-23405 via svnmerge fromdavid23:00, 25 June 2007
Views
Toolbox