Index: branches/wmf/1.18wmf1/tests/phpunit/includes/ExtraParserTest.php |
— | — | @@ -69,14 +69,20 @@ |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * cleanSigInSig() just removes tildes |
| 73 | + * @dataProvider provideStringsForCleanSigInSig |
73 | 74 | */ |
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 ); |
79 | 77 | } |
80 | 78 | |
| 79 | + function provideStringsForCleanSigInSig() { |
| 80 | + return array( |
| 81 | + array( "{{Foo}} ~~~~", "{{Foo}} " ), |
| 82 | + array( "~~~", "" ), |
| 83 | + array( "~~~~~", "" ), |
| 84 | + ); |
| 85 | + } |
| 86 | + |
81 | 87 | function testGetSection() { |
82 | 88 | $outputText2 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 2 ); |
83 | 89 | $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 @@ |
4261 | 4261 | } |
4262 | 4262 | |
4263 | 4263 | # Make sure nickname doesnt get a sig in a sig |
4264 | | - $nickname = $this->cleanSigInSig( $nickname ); |
| 4264 | + $nickname = self::cleanSigInSig( $nickname ); |
4265 | 4265 | |
4266 | 4266 | # If we're still here, make it a link to the user page |
4267 | 4267 | $userText = wfEscapeWikiText( $username ); |
— | — | @@ -4290,7 +4290,7 @@ |
4291 | 4291 | * @param $parsing Whether we're cleaning (preferences save) or parsing |
4292 | 4292 | * @return String: signature text |
4293 | 4293 | */ |
4294 | | - function cleanSig( $text, $parsing = false ) { |
| 4294 | + public function cleanSig( $text, $parsing = false ) { |
4295 | 4295 | if ( !$parsing ) { |
4296 | 4296 | global $wgTitle; |
4297 | 4297 | $this->mOptions = new ParserOptions; |
— | — | @@ -4311,7 +4311,7 @@ |
4312 | 4312 | $substText = '{{' . $substWord->getSynonym( 0 ); |
4313 | 4313 | |
4314 | 4314 | $text = preg_replace( $substRegex, $substText, $text ); |
4315 | | - $text = $this->cleanSigInSig( $text ); |
| 4315 | + $text = self::cleanSigInSig( $text ); |
4316 | 4316 | $dom = $this->preprocessToDom( $text ); |
4317 | 4317 | $frame = $this->getPreprocessor()->newFrame(); |
4318 | 4318 | $text = $frame->expand( $dom ); |
— | — | @@ -4329,7 +4329,7 @@ |
4330 | 4330 | * @param $text String |
4331 | 4331 | * @return String: signature text with /~{3,5}/ removed |
4332 | 4332 | */ |
4333 | | - function cleanSigInSig( $text ) { |
| 4333 | + public static function cleanSigInSig( $text ) { |
4334 | 4334 | $text = preg_replace( '/~{3,5}/', '', $text ); |
4335 | 4335 | return $text; |
4336 | 4336 | } |
Index: branches/wmf/1.18wmf1/includes/Preferences.php |
— | — | @@ -1184,12 +1184,12 @@ |
1185 | 1185 | * @return string |
1186 | 1186 | */ |
1187 | 1187 | static function cleanSignature( $signature, $alldata ) { |
1188 | | - global $wgParser; |
1189 | 1188 | if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) { |
| 1189 | + global $wgParser; |
1190 | 1190 | $signature = $wgParser->cleanSig( $signature ); |
1191 | 1191 | } else { |
1192 | 1192 | // When no fancy sig used, make sure ~{3,5} get removed. |
1193 | | - $signature = $wgParser->cleanSigInSig( $signature ); |
| 1193 | + $signature = Parser::cleanSigInSig( $signature ); |
1194 | 1194 | } |
1195 | 1195 | |
1196 | 1196 | return $signature; |