r106258 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106257‎ | r106258 | r106259 >
Date:22:16, 14 December 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
1.18wmf1: MFT r105377
Modified paths:
  • /branches/wmf/1.18wmf1/includes/Preferences.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/parser/Parser.php (modified) (history)
  • /branches/wmf/1.18wmf1/tests/phpunit/includes/ExtraParserTest.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/tests/phpunit/includes/ExtraParserTest.php
@@ -69,14 +69,20 @@
7070
7171 /**
7272 * cleanSigInSig() just removes tildes
 73+ * @dataProvider provideStringsForCleanSigInSig
7374 */
74 - function testCleanSigInSig() {
75 - $title = Title::newFromText( __FUNCTION__ );
76 - $outputText = $this->parser->cleanSigInSig( "{{Foo}} ~~~~" );
77 -
78 - $this->assertEquals( "{{Foo}} ", $outputText );
 75+ function testCleanSigInSig( $in, $out ) {
 76+ $this->assertEquals( Parser::cleanSigInSig( $in), $out );
7977 }
8078
 79+ function provideStringsForCleanSigInSig() {
 80+ return array(
 81+ array( "{{Foo}} ~~~~", "{{Foo}} " ),
 82+ array( "~~~", "" ),
 83+ array( "~~~~~", "" ),
 84+ );
 85+ }
 86+
8187 function testGetSection() {
8288 $outputText2 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 2 );
8389 $outputText1 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 1 );
Index: branches/wmf/1.18wmf1/includes/parser/Parser.php
@@ -4260,7 +4260,7 @@
42614261 }
42624262
42634263 # Make sure nickname doesnt get a sig in a sig
4264 - $nickname = $this->cleanSigInSig( $nickname );
 4264+ $nickname = self::cleanSigInSig( $nickname );
42654265
42664266 # If we're still here, make it a link to the user page
42674267 $userText = wfEscapeWikiText( $username );
@@ -4290,7 +4290,7 @@
42914291 * @param $parsing Whether we're cleaning (preferences save) or parsing
42924292 * @return String: signature text
42934293 */
4294 - function cleanSig( $text, $parsing = false ) {
 4294+ public function cleanSig( $text, $parsing = false ) {
42954295 if ( !$parsing ) {
42964296 global $wgTitle;
42974297 $this->mOptions = new ParserOptions;
@@ -4311,7 +4311,7 @@
43124312 $substText = '{{' . $substWord->getSynonym( 0 );
43134313
43144314 $text = preg_replace( $substRegex, $substText, $text );
4315 - $text = $this->cleanSigInSig( $text );
 4315+ $text = self::cleanSigInSig( $text );
43164316 $dom = $this->preprocessToDom( $text );
43174317 $frame = $this->getPreprocessor()->newFrame();
43184318 $text = $frame->expand( $dom );
@@ -4329,7 +4329,7 @@
43304330 * @param $text String
43314331 * @return String: signature text with /~{3,5}/ removed
43324332 */
4333 - function cleanSigInSig( $text ) {
 4333+ public static function cleanSigInSig( $text ) {
43344334 $text = preg_replace( '/~{3,5}/', '', $text );
43354335 return $text;
43364336 }
Index: branches/wmf/1.18wmf1/includes/Preferences.php
@@ -1184,12 +1184,12 @@
11851185 * @return string
11861186 */
11871187 static function cleanSignature( $signature, $alldata ) {
1188 - global $wgParser;
11891188 if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) {
 1189+ global $wgParser;
11901190 $signature = $wgParser->cleanSig( $signature );
11911191 } else {
11921192 // When no fancy sig used, make sure ~{3,5} get removed.
1193 - $signature = $wgParser->cleanSigInSig( $signature );
 1193+ $signature = Parser::cleanSigInSig( $signature );
11941194 }
11951195
11961196 return $signature;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r105377Minor tweaks to cleanSig(inSig)...demon23:07, 6 December 2011

Comments

#Comment by Nikerabbit (talk | contribs)   07:48, 15 December 2011

The ~{3,5} really trips gmail and it starts showing garbage after that :/

Status & tagging log