Index: branches/REL1_18/phase3/RELEASE-NOTES-1.18 |
— | — | @@ -20,16 +20,11 @@ |
21 | 21 | * (bug 34528) Edit section tooltips show correction section name again |
22 | 22 | * (bug 34246) MediaWiki:Whatlinkshere-summary message is displayed again in |
23 | 23 | Special:Whatlinkshere |
| 24 | +* (bug 22555) Remove or skip strip markers from tag hooks like <nowiki> in |
| 25 | + core parser functions which operate on strings, such as formatnum. |
24 | 26 | |
25 | | -== MediaWiki 1.18.1 == |
26 | | -2012-01-11 |
27 | | - |
28 | | -This a maintenance and security release of the MediaWiki 1.18 branch. |
29 | | - |
30 | | -=== Security changes === |
31 | | -* (bug 33117) prop=revisions allows deleted text to be exposed through cache pollution. |
32 | | - |
33 | 27 | === Changes since 1.18.0 === |
| 28 | + |
34 | 29 | * (bug 32712) Fix for search indexing of pages with certain unicode chars following URL. |
35 | 30 | * (bug 3901) Lang, hreflang attribs added to sidebar interlanguage links for screen readers. |
36 | 31 | * (bug 30774) mediawiki.html: Add support for numbers and booleans in the |
— | — | @@ -55,6 +50,7 @@ |
56 | 51 | all pages. |
57 | 52 | * Fixed recentchanges FK violation on page delete and cache purge error in updater |
58 | 53 | for Oracle DB. |
| 54 | +* (bug 33117) prop=revisions allows deleted text to be exposed through cache pollution. |
59 | 55 | |
60 | 56 | == MediaWiki 1.18 == |
61 | 57 | 2011-11-24 |
Index: branches/REL1_18/phase3/tests/parser/parserTests.txt |
— | — | @@ -8815,6 +8815,87 @@ |
8816 | 8816 | |
8817 | 8817 | !! end |
8818 | 8818 | |
| 8819 | +!! test |
| 8820 | +Strip marker in urlencode |
| 8821 | +!! input |
| 8822 | +{{urlencode:x<nowiki/>y}} |
| 8823 | +{{urlencode:x<nowiki/>y|wiki}} |
| 8824 | +{{urlencode:x<nowiki/>y|path}} |
| 8825 | +!! result |
| 8826 | +<p>xy |
| 8827 | +xy |
| 8828 | +xy |
| 8829 | +</p> |
| 8830 | +!! end |
| 8831 | + |
| 8832 | +!! test |
| 8833 | +Strip marker in lc |
| 8834 | +!! input |
| 8835 | +{{lc:x<nowiki/>y}} |
| 8836 | +!! result |
| 8837 | +<p>xy |
| 8838 | +</p> |
| 8839 | +!! end |
| 8840 | + |
| 8841 | +!! test |
| 8842 | +Strip marker in uc |
| 8843 | +!! input |
| 8844 | +{{uc:x<nowiki/>y}} |
| 8845 | +!! result |
| 8846 | +<p>XY |
| 8847 | +</p> |
| 8848 | +!! end |
| 8849 | + |
| 8850 | +!! test |
| 8851 | +Strip marker in formatNum |
| 8852 | +!! input |
| 8853 | +{{formatnum:1<nowiki/>2}} |
| 8854 | +{{formatnum:1<nowiki/>2|R}} |
| 8855 | +!! result |
| 8856 | +<p>12 |
| 8857 | +12 |
| 8858 | +</p> |
| 8859 | +!! end |
| 8860 | + |
| 8861 | +!! test |
| 8862 | +Strip marker in grammar |
| 8863 | +!! options |
| 8864 | +language=fi |
| 8865 | +!! input |
| 8866 | +{{grammar:elative|foo<nowiki/>bar}} |
| 8867 | +!! result |
| 8868 | +<p>foobarista |
| 8869 | +</p> |
| 8870 | +!! end |
| 8871 | + |
| 8872 | +!! test |
| 8873 | +Strip marker in padleft |
| 8874 | +!! input |
| 8875 | +{{padleft:|2|x<nowiki/>y}} |
| 8876 | +!! result |
| 8877 | +<p>xy |
| 8878 | +</p> |
| 8879 | +!! end |
| 8880 | + |
| 8881 | +!! test |
| 8882 | +Strip marker in padright |
| 8883 | +!! input |
| 8884 | +{{padright:|2|x<nowiki/>y}} |
| 8885 | +!! result |
| 8886 | +<p>xy |
| 8887 | +</p> |
| 8888 | +!! end |
| 8889 | + |
| 8890 | +!! test |
| 8891 | +Strip marker in anchorencode |
| 8892 | +!! input |
| 8893 | +{{anchorencode:x<nowiki/>y}} |
| 8894 | +!! result |
| 8895 | +<p>xy |
| 8896 | +</p> |
| 8897 | +!! end |
| 8898 | + |
| 8899 | + |
8819 | 8900 | TODO: |
8820 | 8901 | more images |
8821 | 8902 | more tables |
Index: branches/REL1_18/phase3/includes/parser/Parser.php |
— | — | @@ -5403,6 +5403,16 @@ |
5404 | 5404 | } |
5405 | 5405 | |
5406 | 5406 | /** |
| 5407 | + * Remove any strip markers found in the given text. |
| 5408 | + * |
| 5409 | + * @param $text Input string |
| 5410 | + * @return string |
| 5411 | + */ |
| 5412 | + function killMarkers( $text ) { |
| 5413 | + return $this->mStripState->killMarkers( $text ); |
| 5414 | + } |
| 5415 | + |
| 5416 | + /** |
5407 | 5417 | * Save the parser state required to convert the given half-parsed text to |
5408 | 5418 | * HTML. "Half-parsed" in this context means the output of |
5409 | 5419 | * recursiveTagParse() or internalParse(). This output has strip markers |
Index: branches/REL1_18/phase3/includes/parser/CoreParserFunctions.php |
— | — | @@ -164,17 +164,21 @@ |
165 | 165 | |
166 | 166 | // Encode as though it's a wiki page, '_' for ' '. |
167 | 167 | case 'url_wiki': |
168 | | - return wfUrlencode( str_replace( ' ', '_', $s ) ); |
| 168 | + $func = 'wfUrlencode'; |
| 169 | + $s = str_replace( ' ', '_', $s ); |
| 170 | + break; |
169 | 171 | |
170 | 172 | // Encode for an HTTP Path, '%20' for ' '. |
171 | 173 | case 'url_path': |
172 | | - return rawurlencode( $s ); |
| 174 | + $func = 'rawurlencode'; |
| 175 | + break; |
173 | 176 | |
174 | 177 | // Encode for HTTP query, '+' for ' '. |
175 | 178 | case 'url_query': |
176 | 179 | default: |
177 | | - return urlencode( $s ); |
| 180 | + $func = 'urlencode'; |
178 | 181 | } |
| 182 | + return $parser->markerSkipCallback( $s, $func ); |
179 | 183 | } |
180 | 184 | |
181 | 185 | static function lcfirst( $parser, $s = '' ) { |
— | — | @@ -194,11 +198,7 @@ |
195 | 199 | */ |
196 | 200 | static function lc( $parser, $s = '' ) { |
197 | 201 | global $wgContLang; |
198 | | - if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) { |
199 | | - return $parser->markerSkipCallback( $s, array( $wgContLang, 'lc' ) ); |
200 | | - } else { |
201 | | - return $wgContLang->lc( $s ); |
202 | | - } |
| 202 | + return $parser->markerSkipCallback( $s, array( $wgContLang, 'lc' ) ); |
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
— | — | @@ -208,11 +208,7 @@ |
209 | 209 | */ |
210 | 210 | static function uc( $parser, $s = '' ) { |
211 | 211 | global $wgContLang; |
212 | | - if ( is_callable( array( $parser, 'markerSkipCallback' ) ) ) { |
213 | | - return $parser->markerSkipCallback( $s, array( $wgContLang, 'uc' ) ); |
214 | | - } else { |
215 | | - return $wgContLang->uc( $s ); |
216 | | - } |
| 212 | + return $parser->markerSkipCallback( $s, array( $wgContLang, 'uc' ) ); |
217 | 213 | } |
218 | 214 | |
219 | 215 | static function localurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getLocalURL', $s, $arg ); } |
— | — | @@ -252,12 +248,13 @@ |
253 | 249 | * @param null $raw |
254 | 250 | * @return |
255 | 251 | */ |
256 | | - static function formatNum( $parser, $num = '', $raw = null) { |
257 | | - if ( self::israw( $raw ) ) { |
258 | | - return $parser->getFunctionLang()->parseFormattedNumber( $num ); |
| 252 | + static function formatnum( $parser, $num = '', $raw = null) { |
| 253 | + if ( self::isRaw( $raw ) ) { |
| 254 | + $func = array( $parser->getFunctionLang(), 'parseFormattedNumber' ); |
259 | 255 | } else { |
260 | | - return $parser->getFunctionLang()->formatNum( $num ); |
| 256 | + $func = array( $parser->getFunctionLang(), 'formatNum' ); |
261 | 257 | } |
| 258 | + return $parser->markerSkipCallback( $num, $func ); |
262 | 259 | } |
263 | 260 | |
264 | 261 | /** |
— | — | @@ -267,6 +264,7 @@ |
268 | 265 | * @return |
269 | 266 | */ |
270 | 267 | static function grammar( $parser, $case = '', $word = '' ) { |
| 268 | + $word = $parser->killMarkers( $word ); |
271 | 269 | return $parser->getFunctionLang()->convertGrammar( $word, $case ); |
272 | 270 | } |
273 | 271 | |
— | — | @@ -624,7 +622,8 @@ |
625 | 623 | /** |
626 | 624 | * Unicode-safe str_pad with the restriction that $length is forced to be <= 500 |
627 | 625 | */ |
628 | | - static function pad( $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) { |
| 626 | + static function pad( $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) { |
| 627 | + $padding = $parser->killMarkers( $padding ); |
629 | 628 | $lengthOfPadding = mb_strlen( $padding ); |
630 | 629 | if ( $lengthOfPadding == 0 ) return $string; |
631 | 630 | |
— | — | @@ -648,11 +647,11 @@ |
649 | 648 | } |
650 | 649 | |
651 | 650 | static function padleft( $parser, $string = '', $length = 0, $padding = '0' ) { |
652 | | - return self::pad( $string, $length, $padding, STR_PAD_LEFT ); |
| 651 | + return self::pad( $parser, $string, $length, $padding, STR_PAD_LEFT ); |
653 | 652 | } |
654 | 653 | |
655 | 654 | static function padright( $parser, $string = '', $length = 0, $padding = '0' ) { |
656 | | - return self::pad( $string, $length, $padding ); |
| 655 | + return self::pad( $parser, $string, $length, $padding ); |
657 | 656 | } |
658 | 657 | |
659 | 658 | /** |
— | — | @@ -661,6 +660,7 @@ |
662 | 661 | * @return string |
663 | 662 | */ |
664 | 663 | static function anchorencode( $parser, $text ) { |
| 664 | + $text = $parser->killMarkers( $text ); |
665 | 665 | return substr( $parser->guessSectionNameFromWikiText( $text ), 1); |
666 | 666 | } |
667 | 667 | |
Index: branches/REL1_18/phase3/includes/parser/StripState.php |
— | — | @@ -174,5 +174,15 @@ |
175 | 175 | $key = $m[1]; |
176 | 176 | return "{$this->prefix}{$this->tempMergePrefix}-$key" . Parser::MARKER_SUFFIX; |
177 | 177 | } |
| 178 | + |
| 179 | + /** |
| 180 | + * Remove any strip markers found in the given text. |
| 181 | + * |
| 182 | + * @param $text Input string |
| 183 | + * @return string |
| 184 | + */ |
| 185 | + function killMarkers( $text ) { |
| 186 | + return preg_replace( $this->regex, '', $text ); |
| 187 | + } |
178 | 188 | } |
179 | 189 | |