r67044 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67043‎ | r67044 | r67045 >
Date:16:12, 29 May 2010
Author:maxsem
Status:ok (Comments)
Tags:
Comment:
(bug 19940) urldecode dropped during StringFunctions-ParserFunctions merger
Modified paths:
  • /trunk/extensions/ParserFunctions/ParserFunctions.i18n.magic.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions.php (modified) (history)
  • /trunk/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)
  • /trunk/extensions/ParserFunctions/funcsParserTests.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserFunctions/ParserFunctions.i18n.magic.php
@@ -25,6 +25,7 @@
2626 'count' => array( 0, 'count' ),
2727 'replace' => array( 0, 'replace' ),
2828 'explode' => array( 0, 'explode' ),
 29+ 'urldecode' => array( 0, 'urldecode' ),
2930 );
3031
3132 $magicWords['ar'] = array(
Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php
@@ -767,4 +767,24 @@
768768 wfProfileOut( __METHOD__ );
769769 return $result;
770770 }
 771+
 772+ /**
 773+ * {{#urldecode:string}}
 774+ *
 775+ * Decodes URL-encoded (like%20that) strings.
 776+ */
 777+ function runUrlDecode( $parser, $inStr = '' ) {
 778+ wfProfileIn( __METHOD__ );
 779+
 780+ $inStr = $this->killMarkers( $parser, (string)$inStr );
 781+ if ( !$this->checkLength( $inStr ) ) {
 782+ wfProfileOut( __METHOD__ );
 783+ return $this->tooLongError();
 784+ }
 785+
 786+ $result = urldecode( $inStr );
 787+
 788+ wfProfileOut( __METHOD__ );
 789+ return $result;
 790+ }
771791 }
Index: trunk/extensions/ParserFunctions/ParserFunctions.php
@@ -92,13 +92,14 @@
9393
9494 //String Functions
9595 if ( $wgPFEnableStringFunctions ) {
96 - $parser->setFunctionHook( 'len', array(&$this, 'runLen' ));
97 - $parser->setFunctionHook( 'pos', array(&$this, 'runPos' ));
98 - $parser->setFunctionHook( 'rpos', array(&$this, 'runRPos' ));
99 - $parser->setFunctionHook( 'sub', array(&$this, 'runSub' ));
100 - $parser->setFunctionHook( 'count', array(&$this, 'runCount' ));
101 - $parser->setFunctionHook( 'replace', array(&$this, 'runReplace' ));
102 - $parser->setFunctionHook( 'explode', array(&$this, 'runExplode' ));
 96+ $parser->setFunctionHook( 'len', array( &$this, 'runLen' ) );
 97+ $parser->setFunctionHook( 'pos', array( &$this, 'runPos' ) );
 98+ $parser->setFunctionHook( 'rpos', array( &$this, 'runRPos' ) );
 99+ $parser->setFunctionHook( 'sub', array( &$this, 'runSub' ) );
 100+ $parser->setFunctionHook( 'count', array( &$this, 'runCount' ) );
 101+ $parser->setFunctionHook( 'replace', array( &$this, 'runReplace' ) );
 102+ $parser->setFunctionHook( 'explode', array( &$this, 'runExplode' ) );
 103+ $parser->setFunctionHook( 'urldecode', array( &$this, 'runUrlDecode' ) );
103104 }
104105
105106 return true;
Index: trunk/extensions/ParserFunctions/funcsParserTests.txt
@@ -175,3 +175,17 @@
176176 <p>false
177177 </p>
178178 !! end
 179+
 180+!! test
 181+#urldecode
 182+!! input
 183+{{#urldecode:}}
 184+{{#urldecode:foo%20bar}}
 185+{{#urldecode:%D0%9C%D0%B5%D0%B4%D0%B8%D0%B0%D0%92%D0%B8%D0%BA%D0%B8}}
 186+{{#urldecode: some unescaped string}}
 187+!! result
 188+<p>foo bar
 189+МедиаВики
 190+some unescaped string
 191+</p>
 192+!! end

Follow-up revisions

RevisionCommit summaryAuthorDate
r69220Follow-up to r67044: moved string function tests to a separate file protected...maxsem21:11, 9 July 2010

Comments

#Comment by OverlordQ (talk | contribs)   00:52, 9 July 2010

Note that the test will only pass if $wgPFEnableStringFunctions is enabled when the parser tests are run.

Status & tagging log