Merge "Perform a permission check on the title when changing the page language"
[lhc/web/wiklou.git] / includes / parser / CoreTagHooks.php
index 4541c52..438603a 100644 (file)
@@ -59,8 +59,8 @@ class CoreTagHooks {
                // We need to let both '"' and '&' through,
                // for strip markers and entities respectively.
                $content = str_replace(
-                       array( '>', '<' ),
-                       array( '&gt;', '&lt;' ),
+                       [ '>', '<' ],
+                       [ '&gt;', '&lt;' ],
                        $content
                );
                return Html::rawElement( 'pre', $attribs, $content );
@@ -79,12 +79,25 @@ class CoreTagHooks {
         * @param array $attributes
         * @param Parser $parser
         * @throws MWException
-        * @return array
+        * @return array|string Output of tag hook
         */
        public static function html( $content, $attributes, $parser ) {
                global $wgRawHtml;
                if ( $wgRawHtml ) {
-                       return [ $content, 'markerType' => 'nowiki' ];
+                       if ( $parser->getOptions()->getAllowUnsafeRawHtml() ) {
+                               return [ $content, 'markerType' => 'nowiki' ];
+                       } else {
+                               // In a system message where raw html is
+                               // not allowed (but it is allowed in other
+                               // contexts).
+                               return Html::rawElement(
+                                       'span',
+                                       [ 'class' => 'error' ],
+                                       // Using ->text() not ->parse() as
+                                       // a paranoia measure against a loop.
+                                       wfMessage( 'rawhtml-notallowed' )->escaped()
+                               );
+                       }
                } else {
                        throw new MWException( '<html> extension tag encountered unexpectedly' );
                }
@@ -103,7 +116,7 @@ class CoreTagHooks {
         * @return array
         */
        public static function nowiki( $content, $attributes, $parser ) {
-               $content = strtr( $content, array(
+               $content = strtr( $content, [
                        // lang converter
                        '-{' => '-&#123;',
                        '}-' => '&#125;-',
@@ -112,8 +125,8 @@ class CoreTagHooks {
                        '>' => '&gt;'
                        // Note: Both '"' and '&' are not converted.
                        // This allows strip markers and entities through.
-               ) );
-               return array( $content, 'markerType' => 'nowiki' );
+               ] );
+               return [ $content, 'markerType' => 'nowiki' ];
        }
 
        /**