Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
— | — | @@ -88,19 +88,19 @@ |
89 | 89 | return array( 'found' => false ); |
90 | 90 | } |
91 | 91 | } |
92 | | - |
| 92 | + |
93 | 93 | static function formatDate( $parser, $date, $defaultPref = null ) { |
94 | 94 | $df = DateFormatter::getInstance(); |
95 | | - |
| 95 | + |
96 | 96 | $date = trim($date); |
97 | | - |
| 97 | + |
98 | 98 | $pref = $parser->mOptions->getDateFormat(); |
99 | | - |
| 99 | + |
100 | 100 | // Specify a different default date format other than the the normal default |
101 | | - // iff the user has 'default' for their setting |
| 101 | + // iff the user has 'default' for their setting |
102 | 102 | if ($pref == 'default' && $defaultPref) |
103 | 103 | $pref = $defaultPref; |
104 | | - |
| 104 | + |
105 | 105 | $date = $df->reformat( $pref, $date, array('match-whole') ); |
106 | 106 | return $date; |
107 | 107 | } |
— | — | @@ -198,10 +198,10 @@ |
199 | 199 | |
200 | 200 | // default |
201 | 201 | $gender = User::getDefaultOption( 'gender' ); |
202 | | - |
| 202 | + |
203 | 203 | // allow prefix. |
204 | 204 | $title = Title::newFromText( $user ); |
205 | | - |
| 205 | + |
206 | 206 | if (is_object( $title ) && $title->getNamespace() == NS_USER) |
207 | 207 | $user = $title->getText(); |
208 | 208 | |
— | — | @@ -233,13 +233,21 @@ |
234 | 234 | */ |
235 | 235 | static function displaytitle( $parser, $text = '' ) { |
236 | 236 | global $wgRestrictDisplayTitle; |
237 | | - |
| 237 | + |
| 238 | + #parse a limited subset of wiki markup (just the single quote items) |
| 239 | + $text = $parser->doQuotes( $text ); |
| 240 | + |
| 241 | + #remove stripped text (e.g. the UNIQ-QINU stuff) that was generated by tag extensions/whatever |
| 242 | + $text = preg_replace( '/' . preg_quote( $parser->uniqPrefix(), '/' ) . '.*?' |
| 243 | + . preg_quote( Parser::MARKER_SUFFIX, '/' ) . '/', '', $text ); |
| 244 | + |
238 | 245 | #list of disallowed tags for DISPLAYTITLE |
239 | 246 | #these will be escaped even though they are allowed in normal wiki text |
240 | | - $bad = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', |
241 | | - 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rp' ); |
242 | | - |
| 247 | + $bad = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr', |
| 248 | + 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rp', 'br' ); |
| 249 | + |
243 | 250 | #only requested titles that normalize to the actual title are allowed through |
| 251 | + #if $wgRestrictDisplayTitle is true (it is by default) |
244 | 252 | #mimic the escaping process that occurs in OutputPage::setPageTitle |
245 | 253 | $text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $text, null, array(), array(), $bad ) ); |
246 | 254 | $title = Title::newFromText( Sanitizer::stripAllTags( $text ) ); |
— | — | @@ -304,9 +312,9 @@ |
305 | 313 | } |
306 | 314 | static function numberingroup( $parser, $name = '', $raw = null) { |
307 | 315 | return self::formatRaw( SiteStats::numberingroup( strtolower( $name ) ), $raw ); |
308 | | - } |
| 316 | + } |
309 | 317 | |
310 | | - |
| 318 | + |
311 | 319 | /** |
312 | 320 | * Given a title, return the namespace name that would be given by the |
313 | 321 | * corresponding magic word |
— | — | @@ -400,7 +408,7 @@ |
401 | 409 | if ( is_null($t) ) |
402 | 410 | return ''; |
403 | 411 | return wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) ); |
404 | | - } |
| 412 | + } |
405 | 413 | static function talkpagename( $parser, $title = null ) { |
406 | 414 | $t = Title::newFromText( $title ); |
407 | 415 | if ( is_null($t) || !$t->canTalk() ) |
— | — | @@ -425,7 +433,7 @@ |
426 | 434 | return ''; |
427 | 435 | return $t->getSubjectPage()->getPrefixedUrl(); |
428 | 436 | } |
429 | | - |
| 437 | + |
430 | 438 | /** |
431 | 439 | * Return the number of pages in the given category, or 0 if it's nonexis- |
432 | 440 | * tent. This is an expensive parser function and can't be called too many |
— | — | @@ -482,13 +490,13 @@ |
483 | 491 | $rev = Revision::newFromTitle($title); |
484 | 492 | $id = $rev ? $rev->getPage() : 0; |
485 | 493 | $length = $cache[$page] = $rev ? $rev->getSize() : 0; |
486 | | - |
| 494 | + |
487 | 495 | // Register dependency in templatelinks |
488 | 496 | $parser->mOutput->addTemplate( $title, $id, $rev ? $rev->getId() : 0 ); |
489 | | - } |
| 497 | + } |
490 | 498 | return self::formatRaw( $length, $raw ); |
491 | 499 | } |
492 | | - |
| 500 | + |
493 | 501 | /** |
494 | 502 | * Returns the requested protection level for the current page |
495 | 503 | */ |
— | — | @@ -509,12 +517,12 @@ |
510 | 518 | * Unicode-safe str_pad with the restriction that $length is forced to be <= 500 |
511 | 519 | */ |
512 | 520 | static function pad( $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) { |
513 | | - $lengthOfPadding = mb_strlen( $padding ); |
| 521 | + $lengthOfPadding = mb_strlen( $padding ); |
514 | 522 | if ( $lengthOfPadding == 0 ) return $string; |
515 | | - |
| 523 | + |
516 | 524 | # The remaining length to add counts down to 0 as padding is added |
517 | 525 | $length = min( $length, 500 ) - mb_strlen( $string ); |
518 | | - # $finalPadding is just $padding repeated enough times so that |
| 526 | + # $finalPadding is just $padding repeated enough times so that |
519 | 527 | # mb_strlen( $string ) + mb_strlen( $finalPadding ) == $length |
520 | 528 | $finalPadding = ''; |
521 | 529 | while ( $length > 0 ) { |
— | — | @@ -523,7 +531,7 @@ |
524 | 532 | $finalPadding .= mb_substr( $padding, 0, $length ); |
525 | 533 | $length -= $lengthOfPadding; |
526 | 534 | } |
527 | | - |
| 535 | + |
528 | 536 | if ( $direction == STR_PAD_LEFT ) { |
529 | 537 | return $finalPadding . $string; |
530 | 538 | } else { |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -79,6 +79,7 @@ |
80 | 80 | * (bug 14866) Messages 'recentchangeslinked-toolbox' and |
81 | 81 | 'recentchangeslinked-toolbox' were added to allow more fine grained |
82 | 82 | customisation of the user interface |
| 83 | +* DISPLAYTITLE now accepts a limited amount of wiki markup (the single-quote items) |
83 | 84 | |
84 | 85 | === Bug fixes in 1.16 === |
85 | 86 | |