Index: trunk/phase3/tests/phpunit/includes/ExtraParserTest.php |
— | — | @@ -93,14 +93,20 @@ |
94 | 94 | |
95 | 95 | /** |
96 | 96 | * cleanSigInSig() just removes tildes |
| 97 | + * @dataProvider provideStringsForCleanSigInSig |
97 | 98 | */ |
98 | | - function testCleanSigInSig() { |
99 | | - $title = Title::newFromText( __FUNCTION__ ); |
100 | | - $outputText = $this->parser->cleanSigInSig( "{{Foo}} ~~~~" ); |
101 | | - |
102 | | - $this->assertEquals( "{{Foo}} ", $outputText ); |
| 99 | + function testCleanSigInSig( $in, $out ) { |
| 100 | + $this->assertEquals( Parser::cleanSigInSig( $in), $out ); |
103 | 101 | } |
104 | 102 | |
| 103 | + function provideStringsForCleanSigInSig() { |
| 104 | + return array( |
| 105 | + array( "{{Foo}} ~~~~", "{{Foo}} " ), |
| 106 | + array( "~~~", "" ), |
| 107 | + array( "~~~~~", "" ), |
| 108 | + ); |
| 109 | + } |
| 110 | + |
105 | 111 | function testGetSection() { |
106 | 112 | $outputText2 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 2 ); |
107 | 113 | $outputText1 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 1 ); |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -4417,7 +4417,7 @@ |
4418 | 4418 | } |
4419 | 4419 | |
4420 | 4420 | # Make sure nickname doesnt get a sig in a sig |
4421 | | - $nickname = $this->cleanSigInSig( $nickname ); |
| 4421 | + $nickname = self::cleanSigInSig( $nickname ); |
4422 | 4422 | |
4423 | 4423 | # If we're still here, make it a link to the user page |
4424 | 4424 | $userText = wfEscapeWikiText( $username ); |
— | — | @@ -4447,7 +4447,7 @@ |
4448 | 4448 | * @param $parsing bool Whether we're cleaning (preferences save) or parsing |
4449 | 4449 | * @return String: signature text |
4450 | 4450 | */ |
4451 | | - function cleanSig( $text, $parsing = false ) { |
| 4451 | + public function cleanSig( $text, $parsing = false ) { |
4452 | 4452 | if ( !$parsing ) { |
4453 | 4453 | global $wgTitle; |
4454 | 4454 | $this->startParse( $wgTitle, new ParserOptions, self::OT_PREPROCESS, true ); |
— | — | @@ -4465,7 +4465,7 @@ |
4466 | 4466 | $substText = '{{' . $substWord->getSynonym( 0 ); |
4467 | 4467 | |
4468 | 4468 | $text = preg_replace( $substRegex, $substText, $text ); |
4469 | | - $text = $this->cleanSigInSig( $text ); |
| 4469 | + $text = self::cleanSigInSig( $text ); |
4470 | 4470 | $dom = $this->preprocessToDom( $text ); |
4471 | 4471 | $frame = $this->getPreprocessor()->newFrame(); |
4472 | 4472 | $text = $frame->expand( $dom ); |
— | — | @@ -4483,7 +4483,7 @@ |
4484 | 4484 | * @param $text String |
4485 | 4485 | * @return String: signature text with /~{3,5}/ removed |
4486 | 4486 | */ |
4487 | | - function cleanSigInSig( $text ) { |
| 4487 | + public static function cleanSigInSig( $text ) { |
4488 | 4488 | $text = preg_replace( '/~{3,5}/', '', $text ); |
4489 | 4489 | return $text; |
4490 | 4490 | } |
Index: trunk/phase3/includes/Preferences.php |
— | — | @@ -1186,12 +1186,12 @@ |
1187 | 1187 | * @return string |
1188 | 1188 | */ |
1189 | 1189 | static function cleanSignature( $signature, $alldata, $form ) { |
1190 | | - global $wgParser; |
1191 | 1190 | if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) { |
| 1191 | + global $wgParser; |
1192 | 1192 | $signature = $wgParser->cleanSig( $signature ); |
1193 | 1193 | } else { |
1194 | 1194 | // When no fancy sig used, make sure ~{3,5} get removed. |
1195 | | - $signature = $wgParser->cleanSigInSig( $signature ); |
| 1195 | + $signature = Parser::cleanSigInSig( $signature ); |
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | return $signature; |