Remove ~{3,5} in Nickname when saving the preferences. Make sure
authorAntoine Musso <hashar@users.mediawiki.org>
Fri, 23 Jun 2006 19:50:55 +0000 (19:50 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Fri, 23 Jun 2006 19:50:55 +0000 (19:50 +0000)
sig in sig get removed even when fancy username is disabled or
nickname is empty.

includes/Parser.php
includes/SpecialPreferences.php

index 56373b9..ada0a5f 100644 (file)
@@ -3742,6 +3742,9 @@ class Parser
                        }
                }
 
+               // Make sure nickname doesnt get a sig in a sig
+               $nickname = $this->cleanSigInSig( $nickname );
+
                # If we're still here, make it a link to the user page
                $userpage = $user->getUserPage();
                return( '[[' . $userpage->getPrefixedText() . '|' . wfEscapeWikiText( $nickname ) . ']]' );
@@ -3760,7 +3763,7 @@ class Parser
        /**
         * Clean up signature text
         *
-        * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures
+        * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures @see cleanSigInSig
         * 2) Substitute all transclusions
         *
         * @param string $text
@@ -3776,12 +3779,22 @@ class Parser
                $substText = '{{' . $substWord->getSynonym( 0 );
 
                $text = preg_replace( $substRegex, $substText, $text );
-               $text = preg_replace( '/~{3,5}/', '', $text );
+               $text = cleanSigInSig( $text );
                $text = $this->replaceVariables( $text );
                
                $this->clearState();    
                return $text;
        }
+
+       /**
+        * Strip ~~~, ~~~~ and ~~~~~ out of signatures
+        * @param string $text
+        * @return string Signature text with /~{3,5}/ removed
+        */
+       function cleanSigInSig( $text ) {
+               $text = preg_replace( '/~{3,5}/', '', $text );
+               return $text;
+       }
        
        /**
         * Set up some variables which are usually set up in parse()
index b4a5669..9faba35 100644 (file)
@@ -243,6 +243,9 @@ class PreferencesForm {
                        } else {
                                $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) );
                        }
+               } else {
+                       // When no fancy sig used, make sure ~{3,5} get removed.
+                       $this->mNick = $wgParser->cleanSigInSig( $this->mNick );
                }
 
                $wgUser->setOption( 'language', $this->mUserLanguage );