https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114338
Revision: 114338
Author: tstarling
Date: 2012-03-21 00:31:52 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------
Backported the bug 22555 part of r114232 and cleaned up RELEASE-NOTES-1.18
Modified Paths:
--------------
branches/REL1_18/phase3/RELEASE-NOTES-1.18
branches/REL1_18/phase3/includes/parser/CoreParserFunctions.php
branches/REL1_18/phase3/includes/parser/Parser.php
branches/REL1_18/phase3/includes/parser/StripState.php
branches/REL1_18/phase3/tests/parser/parserTests.txt
Modified: branches/REL1_18/phase3/RELEASE-NOTES-1.18
===================================================================
--- branches/REL1_18/phase3/RELEASE-NOTES-1.18 2012-03-21 00:25:06 UTC (rev
114337)
+++ branches/REL1_18/phase3/RELEASE-NOTES-1.18 2012-03-21 00:31:52 UTC (rev
114338)
@@ -20,16 +20,11 @@
* (bug 34528) Edit section tooltips show correction section name again
* (bug 34246) MediaWiki:Whatlinkshere-summary message is displayed again in
Special:Whatlinkshere
+* (bug 22555) Remove or skip strip markers from tag hooks like <nowiki>
in
+ core parser functions which operate on strings, such as formatnum.
-== MediaWiki 1.18.1 ==
-2012-01-11
-
-This a maintenance and security release of the MediaWiki 1.18 branch.
-
-=== Security changes ===
-* (bug 33117) prop=revisions allows deleted text to be exposed through cache
pollution.
-
=== Changes since 1.18.0 ===
+
* (bug 32712) Fix for search indexing of pages with certain unicode chars
following URL.
* (bug 3901) Lang, hreflang attribs added to sidebar interlanguage links for
screen readers.
* (bug 30774) mediawiki.html: Add support for numbers and booleans in the
@@ -55,6 +50,7 @@
all pages.
* Fixed recentchanges FK violation on page delete and cache purge error in
updater
for Oracle DB.
+* (bug 33117) prop=revisions allows deleted text to be exposed through cache
pollution.
== MediaWiki 1.18 ==
2011-11-24
Modified: branches/REL1_18/phase3/includes/parser/CoreParserFunctions.php
===================================================================
--- branches/REL1_18/phase3/includes/parser/CoreParserFunctions.php
2012-03-21 00:25:06 UTC (rev 114337)
+++ branches/REL1_18/phase3/includes/parser/CoreParserFunctions.php
2012-03-21 00:31:52 UTC (rev 114338)
@@ -164,17 +164,21 @@
// 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 @@
*/
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 @@
*/
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 @@
* @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 @@
* @return
*/
static function grammar( $parser, $case = '', $word = '' ) {
+ $word = $parser->killMarkers( $word );
return $parser->getFunctionLang()->convertGrammar( $word, $case
);
}
@@ -624,7 +622,8 @@
/**
* 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 @@
}
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 @@
* @return string
*/
static function anchorencode( $parser, $text ) {
+ $text = $parser->killMarkers( $text );
return substr( $parser->guessSectionNameFromWikiText( $text ),
1);
}
Modified: branches/REL1_18/phase3/includes/parser/Parser.php
===================================================================
--- branches/REL1_18/phase3/includes/parser/Parser.php 2012-03-21 00:25:06 UTC
(rev 114337)
+++ branches/REL1_18/phase3/includes/parser/Parser.php 2012-03-21 00:31:52 UTC
(rev 114338)
@@ -5403,6 +5403,16 @@
}
/**
+ * 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
Modified: branches/REL1_18/phase3/includes/parser/StripState.php
===================================================================
--- branches/REL1_18/phase3/includes/parser/StripState.php 2012-03-21
00:25:06 UTC (rev 114337)
+++ branches/REL1_18/phase3/includes/parser/StripState.php 2012-03-21
00:31:52 UTC (rev 114338)
@@ -174,5 +174,15 @@
$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 );
+ }
}
Modified: branches/REL1_18/phase3/tests/parser/parserTests.txt
===================================================================
--- branches/REL1_18/phase3/tests/parser/parserTests.txt 2012-03-21
00:25:06 UTC (rev 114337)
+++ branches/REL1_18/phase3/tests/parser/parserTests.txt 2012-03-21
00:31:52 UTC (rev 114338)
@@ -8815,6 +8815,87 @@
!! end
+!! test
+Strip marker in urlencode
+!! input
+{{urlencode:x<nowiki/>y}}
+{{urlencode:x<nowiki/>y|wiki}}
+{{urlencode:x<nowiki/>y|path}}
+!! result
+<p>xy
+xy
+xy
+</p>
+!! end
+
+!! test
+Strip marker in lc
+!! input
+{{lc:x<nowiki/>y}}
+!! result
+<p>xy
+</p>
+!! end
+
+!! test
+Strip marker in uc
+!! input
+{{uc:x<nowiki/>y}}
+!! result
+<p>XY
+</p>
+!! end
+
+!! test
+Strip marker in formatNum
+!! input
+{{formatnum:1<nowiki/>2}}
+{{formatnum:1<nowiki/>2|R}}
+!! result
+<p>12
+12
+</p>
+!! end
+
+!! test
+Strip marker in grammar
+!! options
+language=fi
+!! input
+{{grammar:elative|foo<nowiki/>bar}}
+!! result
+<p>foobarista
+</p>
+!! end
+
+!! test
+Strip marker in padleft
+!! input
+{{padleft:|2|x<nowiki/>y}}
+!! result
+<p>xy
+</p>
+!! end
+
+!! test
+Strip marker in padright
+!! input
+{{padright:|2|x<nowiki/>y}}
+!! result
+<p>xy
+</p>
+!! end
+
+!! test
+Strip marker in anchorencode
+!! input
+{{anchorencode:x<nowiki/>y}}
+!! result
+<p>xy
+</p>
+!! end
+
+
TODO:
more images
more tables
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs