From 7e5472dea3e5b1ae020658be470efd5796494ac9 Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Tue, 18 Jan 2011 20:15:50 +0000 Subject: [PATCH] followup r80511: make {{PAGENAMEE}} and friends also call wfEscapeWikiText() (why is the code duplicated, anyway??) --- includes/parser/CoreParserFunctions.php | 16 ++++++++-------- includes/parser/Parser.php | 12 ++++++------ tests/parser/parserTests.txt | 11 +++++++++++ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index e9f3c4c29d..a98c5d3e44 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -409,7 +409,7 @@ class CoreParserFunctions { $t = Title::newFromText( $title ); if ( is_null( $t ) ) return ''; - return $t->getPartialURL(); + return wfEscapeWikiText( $t->getPartialURL() ); } static function fullpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); @@ -421,31 +421,31 @@ class CoreParserFunctions { $t = Title::newFromText( $title ); if ( is_null( $t ) || !$t->canTalk() ) return ''; - return $t->getPrefixedURL(); + return wfEscapeWikiText( $t->getPrefixedURL() ); } static function subpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) return ''; - return $t->getSubpageText(); + return wfEscapeWikiText( $t->getSubpageText() ); } static function subpagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) return ''; - return $t->getSubpageUrlForm(); + return wfEscapeWikiText( $t->getSubpageUrlForm() ); } static function basepagename( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) return ''; - return $t->getBaseText(); + return wfEscapeWikiText( $t->getBaseText() ); } static function basepagenamee( $parser, $title = null ) { $t = Title::newFromText( $title ); if ( is_null( $t ) ) return ''; - return wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) ); + return wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) ) ); } static function talkpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); @@ -457,7 +457,7 @@ class CoreParserFunctions { $t = Title::newFromText( $title ); if ( is_null( $t ) || !$t->canTalk() ) return ''; - return $t->getTalkPage()->getPrefixedUrl(); + return wfEscapeWikiText( $t->getTalkPage()->getPrefixedUrl() ); } static function subjectpagename( $parser, $title = null ) { $t = Title::newFromText( $title ); @@ -469,7 +469,7 @@ class CoreParserFunctions { $t = Title::newFromText( $title ); if ( is_null( $t ) ) return ''; - return $t->getSubjectPage()->getPrefixedUrl(); + return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedUrl() ); } /** diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 2ea87e185a..5266693e08 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2593,25 +2593,25 @@ class Parser { $value = wfEscapeWikiText( $this->mTitle->getText() ); break; case 'pagenamee': - $value = $this->mTitle->getPartialURL(); + $value = wfEscapeWikiText( $this->mTitle->getPartialURL() ); break; case 'fullpagename': $value = wfEscapeWikiText( $this->mTitle->getPrefixedText() ); break; case 'fullpagenamee': - $value = $this->mTitle->getPrefixedURL(); + $value = wfEscapeWikiText( $this->mTitle->getPrefixedURL() ); break; case 'subpagename': $value = wfEscapeWikiText( $this->mTitle->getSubpageText() ); break; case 'subpagenamee': - $value = $this->mTitle->getSubpageUrlForm(); + $value = wfEscapeWikiText( $this->mTitle->getSubpageUrlForm() ); break; case 'basepagename': $value = wfEscapeWikiText( $this->mTitle->getBaseText() ); break; case 'basepagenamee': - $value = wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getBaseText() ) ); + $value = wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getBaseText() ) ) ); break; case 'talkpagename': if ( $this->mTitle->canTalk() ) { @@ -2624,7 +2624,7 @@ class Parser { case 'talkpagenamee': if ( $this->mTitle->canTalk() ) { $talkPage = $this->mTitle->getTalkPage(); - $value = $talkPage->getPrefixedUrl(); + $value = wfEscapeWikiText( $talkPage->getPrefixedUrl() ); } else { $value = ''; } @@ -2635,7 +2635,7 @@ class Parser { break; case 'subjectpagenamee': $subjPage = $this->mTitle->getSubjectPage(); - $value = $subjPage->getPrefixedUrl(); + $value = wfEscapeWikiText( $subjPage->getPrefixedUrl() ); break; case 'revisionid': # Let the edit saving system know we should parse the page diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 08d83af601..20e1c77fee 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -2259,6 +2259,17 @@ title=[[User:Ævar Arnfjörð Bjarmason]]

!! end +!! test +Magic Word: {{PAGENAMEE}} with metacharacters (bug 26781) +!! options +title=[[*RFC 1234 http://example.com/]] +!! input +{{PAGENAMEE}} +!! result +

*RFC_1234_http://example.com/ +

+!! end + !! test Magic Word: {{REVISIONID}} !! input -- 2.20.1