summaryrefslogtreecommitdiff
path: root/includes/parser
diff options
context:
space:
mode:
Diffstat (limited to 'includes/parser')
-rw-r--r--includes/parser/CoreParserFunctions.php40
-rw-r--r--includes/parser/Parser.php10
-rw-r--r--includes/parser/StripState.php10
3 files changed, 40 insertions, 20 deletions
diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php
index eebed44c..080da602 100644
--- a/includes/parser/CoreParserFunctions.php
+++ b/includes/parser/CoreParserFunctions.php
@@ -164,17 +164,21 @@ class CoreParserFunctions {
// Encode as though it's a wiki page, '_' for ' '.
case 'url_wiki':
- return wfUrlencode( str_replace( ' ', '_', $s ) );
+ $func = 'wfUrlencode';
+ $s = str_replace( ' ', '_', $s );
+ break;
// Encode for an HTTP Path, '%20' for ' '.
case 'url_path':
- return rawurlencode( $s );
+ $func = 'rawurlencode';
+ break;
// Encode for HTTP query, '+' for ' '.
case 'url_query':
default:
- return urlencode( $s );
+ $func = 'urlencode';
}
+ return $parser->markerSkipCallback( $s, $func );
}
static function lcfirst( $parser, $s = '' ) {
@@ -194,11 +198,7 @@ class CoreParserFunctions {
*/
static function lc( $parser, $s = '' ) {
global $wgContLang;
- if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) {
- return $parser->markerSkipCallback( $s, array( $wgContLang, 'lc' ) );
- } else {
- return $wgContLang->lc( $s );
- }
+ return $parser->markerSkipCallback( $s, array( $wgContLang, 'lc' ) );
}
/**
@@ -208,11 +208,7 @@ class CoreParserFunctions {
*/
static function uc( $parser, $s = '' ) {
global $wgContLang;
- if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) {
- return $parser->markerSkipCallback( $s, array( $wgContLang, 'uc' ) );
- } else {
- return $wgContLang->uc( $s );
- }
+ return $parser->markerSkipCallback( $s, array( $wgContLang, 'uc' ) );
}
static function localurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getLocalURL', $s, $arg ); }
@@ -252,12 +248,13 @@ class CoreParserFunctions {
* @param null $raw
* @return
*/
- static function formatNum( $parser, $num = '', $raw = null) {
- if ( self::israw( $raw ) ) {
- return $parser->getFunctionLang()->parseFormattedNumber( $num );
+ static function formatnum( $parser, $num = '', $raw = null) {
+ if ( self::isRaw( $raw ) ) {
+ $func = array( $parser->getFunctionLang(), 'parseFormattedNumber' );
} else {
- return $parser->getFunctionLang()->formatNum( $num );
+ $func = array( $parser->getFunctionLang(), 'formatNum' );
}
+ return $parser->markerSkipCallback( $num, $func );
}
/**
@@ -267,6 +264,7 @@ class CoreParserFunctions {
* @return
*/
static function grammar( $parser, $case = '', $word = '' ) {
+ $word = $parser->killMarkers( $word );
return $parser->getFunctionLang()->convertGrammar( $word, $case );
}
@@ -624,7 +622,8 @@ class CoreParserFunctions {
/**
* Unicode-safe str_pad with the restriction that $length is forced to be <= 500
*/
- static function pad( $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) {
+ static function pad( $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) {
+ $padding = $parser->killMarkers( $padding );
$lengthOfPadding = mb_strlen( $padding );
if ( $lengthOfPadding == 0 ) return $string;
@@ -648,11 +647,11 @@ class CoreParserFunctions {
}
static function padleft( $parser, $string = '', $length = 0, $padding = '0' ) {
- return self::pad( $string, $length, $padding, STR_PAD_LEFT );
+ return self::pad( $parser, $string, $length, $padding, STR_PAD_LEFT );
}
static function padright( $parser, $string = '', $length = 0, $padding = '0' ) {
- return self::pad( $string, $length, $padding );
+ return self::pad( $parser, $string, $length, $padding );
}
/**
@@ -661,6 +660,7 @@ class CoreParserFunctions {
* @return string
*/
static function anchorencode( $parser, $text ) {
+ $text = $parser->killMarkers( $text );
return substr( $parser->guessSectionNameFromWikiText( $text ), 1);
}
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index b6443fdb..939d9e3f 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -5403,6 +5403,16 @@ class Parser {
}
/**
+ * Remove any strip markers found in the given text.
+ *
+ * @param $text Input string
+ * @return string
+ */
+ function killMarkers( $text ) {
+ return $this->mStripState->killMarkers( $text );
+ }
+
+ /**
* Save the parser state required to convert the given half-parsed text to
* HTML. "Half-parsed" in this context means the output of
* recursiveTagParse() or internalParse(). This output has strip markers
diff --git a/includes/parser/StripState.php b/includes/parser/StripState.php
index 357dc2c8..a6eff70e 100644
--- a/includes/parser/StripState.php
+++ b/includes/parser/StripState.php
@@ -174,5 +174,15 @@ class StripState {
$key = $m[1];
return "{$this->prefix}{$this->tempMergePrefix}-$key" . Parser::MARKER_SUFFIX;
}
+
+ /**
+ * Remove any strip markers found in the given text.
+ *
+ * @param $text Input string
+ * @return string
+ */
+ function killMarkers( $text ) {
+ return preg_replace( $this->regex, '', $text );
+ }
}