protected $mProfiler;
/**
- * @var \MediaWiki\Linker\LinkRenderer
+ * @var LinkRenderer
*/
protected $mLinkRenderer;
}
/**
- * Get a \MediaWiki\Linker\LinkRenderer instance to make links with
+ * Get a LinkRenderer instance to make links with
*
* @since 1.28
- * @return \MediaWiki\Linker\LinkRenderer
+ * @return LinkRenderer
*/
public function getLinkRenderer() {
if ( !$this->mLinkRenderer ) {
* @return string
*/
public function extensionSubstitution( $params, $frame ) {
+ static $errorStr = '<span class="error">';
+ static $errorLen = 20;
+
$name = $frame->expand( $params['name'] );
+ if ( substr( $name, 0, $errorLen ) === $errorStr ) {
+ // Probably expansion depth or node count exceeded. Just punt the
+ // error up.
+ return $name;
+ }
+
$attrText = !isset( $params['attr'] ) ? null : $frame->expand( $params['attr'] );
+ if ( substr( $attrText, 0, $errorLen ) === $errorStr ) {
+ // See above
+ return $attrText;
+ }
+
$content = !isset( $params['inner'] ) ? null : $frame->expand( $params['inner'] );
+ if ( substr( $content, 0, $errorLen ) === $errorStr ) {
+ // See above
+ return $content;
+ }
+
$marker = self::MARKER_PREFIX . "-$name-"
. sprintf( '%08X', $this->mMarkerIndex++ ) . self::MARKER_SUFFIX;
$output = "<$name$attrText/>";
} else {
$close = is_null( $params['close'] ) ? '' : $frame->expand( $params['close'] );
+ if ( substr( $close, 0, $errorLen ) === $errorStr ) {
+ // See above
+ return $close;
+ }
$output = "<$name$attrText>$content$close";
}
}
# * <b> (r105284)
# * <bdi> (bug 72884)
# * <span dir="rtl"> and <span dir="ltr"> (bug 35167)
+ # * <s> and <strike> (T35715)
# We strip any parameter from accepted tags (second regex), except dir="rtl|ltr" from <span>,
# to allow setting directionality in toc items.
$tocline = preg_replace(
[
- '#<(?!/?(span|sup|sub|bdi|i|b)(?: [^>]*)?>).*?>#',
- '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|bdi|i|b))(?: .*?)?>#'
+ '#<(?!/?(span|sup|sub|bdi|i|b|s|strike)(?: [^>]*)?>).*?>#',
+ '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|bdi|i|b|s|strike))(?: .*?)?>#'
],
[ '', '<$1>' ],
$safeHeadline
OutputPage::setupOOUI();
$this->mOutput->setEnableOOUI( true );
}
-
- /**
- * Escapes the given text so that it may be output using addWikiText()
- * without any linking, formatting, etc. making its way through. This
- * is achieved by substituting certain characters with HTML entities.
- * As required by the callers, "<nowiki>" is not used.
- *
- * @since 1.28
- *
- * @param string $text Text to be escaped
- * @return string
- */
- public function escapeWikitext( $text ) {
- static $repl = null, $repl2 = null;
- if ( $repl === null ) {
- $repl = [
- '"' => '"', '&' => '&', "'" => ''', '<' => '<',
- '=' => '=', '>' => '>', '[' => '[', ']' => ']',
- '{' => '{', '|' => '|', '}' => '}', ';' => ';',
- "\n#" => "\n#", "\r#" => "\r#",
- "\n*" => "\n*", "\r*" => "\r*",
- "\n:" => "\n:", "\r:" => "\r:",
- "\n " => "\n ", "\r " => "\r ",
- "\n\n" => "\n ", "\r\n" => " \n",
- "\n\r" => "\n ", "\r\r" => "\r ",
- "\n\t" => "\n	", "\r\t" => "\r	", // "\n\t\n" is treated like "\n\n"
- "\n----" => "\n----", "\r----" => "\r----",
- '__' => '__', '://' => '://',
- ];
-
- $magicLinks = array_keys( array_filter( [
- 'ISBN' => $this->mOptions->getMagicISBNLinks(),
- 'PMID' => $this->mOptions->getMagicPMIDLinks(),
- 'RFC' => $this->mOptions->getMagicRFCLinks(),
- ] ) );
- // We have to catch everything "\s" matches in PCRE
- foreach ( $magicLinks as $magic ) {
- $repl["$magic "] = "$magic ";
- $repl["$magic\t"] = "$magic	";
- $repl["$magic\r"] = "$magic ";
- $repl["$magic\n"] = "$magic ";
- $repl["$magic\f"] = "$magic";
- }
-
- // And handle protocols that don't use "://"
- global $wgUrlProtocols;
- $repl2 = [];
- foreach ( $wgUrlProtocols as $prot ) {
- if ( substr( $prot, -1 ) === ':' ) {
- $repl2[] = preg_quote( substr( $prot, 0, -1 ), '/' );
- }
- }
- $repl2 = $repl2 ? '/\b(' . implode( '|', $repl2 ) . '):/i' : '/^(?!)/';
- }
- $text = substr( strtr( "\n$text", $repl ), 1 );
- $text = preg_replace( $repl2, '$1:', $text );
- return $text;
- }
}