From d0dbebb4c143de083a96d4248133849ac06d1cbe Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Fri, 23 Jun 2006 19:50:55 +0000 Subject: [PATCH] Remove ~{3,5} in Nickname when saving the preferences. Make sure sig in sig get removed even when fancy username is disabled or nickname is empty. --- includes/Parser.php | 17 +++++++++++++++-- includes/SpecialPreferences.php | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 56373b9433..ada0a5f97f 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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() diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index b4a566935e..9faba35baf 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -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 ); -- 2.20.1