* (bug 10338) Enforce signature length limit in Unicode characters instead of bytes
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 25 Jun 2007 15:02:46 +0000 (15:02 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 25 Jun 2007 15:02:46 +0000 (15:02 +0000)
Uses mb_strlen(), which we already have a fallback function for if mbstring extension isn't present.

RELEASE-NOTES
includes/DefaultSettings.php
includes/Parser.php
includes/SpecialPreferences.php

index 3f60cb4..08d50df 100644 (file)
@@ -101,6 +101,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   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 ==
 
index ea83f64..5a81b71 100644 (file)
@@ -857,7 +857,7 @@ $wgRedirectSources = false;
 
 $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 4f4fdf0..50f9ac1 100644 (file)
@@ -3812,7 +3812,7 @@ class Parser
                $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 49c562d..f80e6b5 100644 (file)
@@ -242,7 +242,7 @@ class PreferencesForm {
 
                # 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 @@ class PreferencesForm {
                }
 
                global $wgParser, $wgMaxSigChars;
-               if( strlen( $this->mNick ) > $wgMaxSigChars ) {
+               if( mb_strlen( $this->mNick ) > $wgMaxSigChars ) {
                        $invalidSig = $this->tableRow(
                                '&nbsp;',
                                Xml::element( 'span', array( 'class' => 'error' ),
@@ -632,10 +632,10 @@ class PreferencesForm {
                                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 .