r80512 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80511‎ | r80512 | r80513 >
Date:20:15, 18 January 2011
Author:vyznev
Status:ok (Comments)
Tags:
Comment:
followup r80511: make {{PAGENAMEE}} and friends also call wfEscapeWikiText() (why is the code duplicated, anyway??)
Modified paths:
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/tests/parser/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/parser/parserTests.txt
@@ -2260,6 +2260,17 @@
22612261 !! end
22622262
22632263 !! test
 2264+Magic Word: {{PAGENAMEE}} with metacharacters (bug 26781)
 2265+!! options
 2266+title=[[*RFC 1234 http://example.com/]]
 2267+!! input
 2268+{{PAGENAMEE}}
 2269+!! result
 2270+<p>&#42;RFC_1234_http&#58;//example.com/
 2271+</p>
 2272+!! end
 2273+
 2274+!! test
22642275 Magic Word: {{REVISIONID}}
22652276 !! input
22662277 {{REVISIONID}}
Index: trunk/phase3/includes/parser/Parser.php
@@ -2593,25 +2593,25 @@
25942594 $value = wfEscapeWikiText( $this->mTitle->getText() );
25952595 break;
25962596 case 'pagenamee':
2597 - $value = $this->mTitle->getPartialURL();
 2597+ $value = wfEscapeWikiText( $this->mTitle->getPartialURL() );
25982598 break;
25992599 case 'fullpagename':
26002600 $value = wfEscapeWikiText( $this->mTitle->getPrefixedText() );
26012601 break;
26022602 case 'fullpagenamee':
2603 - $value = $this->mTitle->getPrefixedURL();
 2603+ $value = wfEscapeWikiText( $this->mTitle->getPrefixedURL() );
26042604 break;
26052605 case 'subpagename':
26062606 $value = wfEscapeWikiText( $this->mTitle->getSubpageText() );
26072607 break;
26082608 case 'subpagenamee':
2609 - $value = $this->mTitle->getSubpageUrlForm();
 2609+ $value = wfEscapeWikiText( $this->mTitle->getSubpageUrlForm() );
26102610 break;
26112611 case 'basepagename':
26122612 $value = wfEscapeWikiText( $this->mTitle->getBaseText() );
26132613 break;
26142614 case 'basepagenamee':
2615 - $value = wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getBaseText() ) );
 2615+ $value = wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getBaseText() ) ) );
26162616 break;
26172617 case 'talkpagename':
26182618 if ( $this->mTitle->canTalk() ) {
@@ -2624,7 +2624,7 @@
26252625 case 'talkpagenamee':
26262626 if ( $this->mTitle->canTalk() ) {
26272627 $talkPage = $this->mTitle->getTalkPage();
2628 - $value = $talkPage->getPrefixedUrl();
 2628+ $value = wfEscapeWikiText( $talkPage->getPrefixedUrl() );
26292629 } else {
26302630 $value = '';
26312631 }
@@ -2635,7 +2635,7 @@
26362636 break;
26372637 case 'subjectpagenamee':
26382638 $subjPage = $this->mTitle->getSubjectPage();
2639 - $value = $subjPage->getPrefixedUrl();
 2639+ $value = wfEscapeWikiText( $subjPage->getPrefixedUrl() );
26402640 break;
26412641 case 'revisionid':
26422642 # Let the edit saving system know we should parse the page
Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -409,7 +409,7 @@
410410 $t = Title::newFromText( $title );
411411 if ( is_null( $t ) )
412412 return '';
413 - return $t->getPartialURL();
 413+ return wfEscapeWikiText( $t->getPartialURL() );
414414 }
415415 static function fullpagename( $parser, $title = null ) {
416416 $t = Title::newFromText( $title );
@@ -421,31 +421,31 @@
422422 $t = Title::newFromText( $title );
423423 if ( is_null( $t ) || !$t->canTalk() )
424424 return '';
425 - return $t->getPrefixedURL();
 425+ return wfEscapeWikiText( $t->getPrefixedURL() );
426426 }
427427 static function subpagename( $parser, $title = null ) {
428428 $t = Title::newFromText( $title );
429429 if ( is_null( $t ) )
430430 return '';
431 - return $t->getSubpageText();
 431+ return wfEscapeWikiText( $t->getSubpageText() );
432432 }
433433 static function subpagenamee( $parser, $title = null ) {
434434 $t = Title::newFromText( $title );
435435 if ( is_null( $t ) )
436436 return '';
437 - return $t->getSubpageUrlForm();
 437+ return wfEscapeWikiText( $t->getSubpageUrlForm() );
438438 }
439439 static function basepagename( $parser, $title = null ) {
440440 $t = Title::newFromText( $title );
441441 if ( is_null( $t ) )
442442 return '';
443 - return $t->getBaseText();
 443+ return wfEscapeWikiText( $t->getBaseText() );
444444 }
445445 static function basepagenamee( $parser, $title = null ) {
446446 $t = Title::newFromText( $title );
447447 if ( is_null( $t ) )
448448 return '';
449 - return wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) );
 449+ return wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) ) );
450450 }
451451 static function talkpagename( $parser, $title = null ) {
452452 $t = Title::newFromText( $title );
@@ -457,7 +457,7 @@
458458 $t = Title::newFromText( $title );
459459 if ( is_null( $t ) || !$t->canTalk() )
460460 return '';
461 - return $t->getTalkPage()->getPrefixedUrl();
 461+ return wfEscapeWikiText( $t->getTalkPage()->getPrefixedUrl() );
462462 }
463463 static function subjectpagename( $parser, $title = null ) {
464464 $t = Title::newFromText( $title );
@@ -469,7 +469,7 @@
470470 $t = Title::newFromText( $title );
471471 if ( is_null( $t ) )
472472 return '';
473 - return $t->getSubjectPage()->getPrefixedUrl();
 473+ return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedUrl() );
474474 }
475475
476476 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80511bug 26781: make wfEscapeWikiText() escape "*", "#", ";" and ":" at the beginn...vyznev19:39, 18 January 2011

Comments

#Comment by Tim Starling (talk | contribs)   05:50, 5 September 2011

It's duplicated because "variables" like {{SUBPAGENAME}} are different from parser functions, which have a colon in the function call, like {{SUBPAGENAME:Foo/Bar}}.

Status & tagging log