Merge "RCFilters: Minimize url string"
[lhc/web/wiklou.git] / includes / parser / ParserOptions.php
index 7be8281..d097414 100644 (file)
@@ -243,6 +243,27 @@ class ParserOptions {
         */
        private $redirectTarget = null;
 
+       /**
+        * If the wiki is configured to allow raw html ($wgRawHtml = true)
+        * is it allowed in the specific case of parsing this page.
+        *
+        * This is meant to disable unsafe parser tags in cases where
+        * a malicious user may control the input to the parser.
+        *
+        * @note This is expected to be true for normal pages even if the
+        *  wiki has $wgRawHtml disabled in general. The setting only
+        *  signifies that raw html would be unsafe in the current context
+        *  provided that raw html is allowed at all.
+        * @var boolean
+        */
+       private $allowUnsafeRawHtml = true;
+
+       /**
+        * CSS class to use to wrap output from Parser::parse().
+        * @var string|false
+        */
+       private $wrapOutputClass = 'mw-parser-output';
+
        public function getInterwikiMagic() {
                return $this->mInterwikiMagic;
        }
@@ -457,6 +478,25 @@ class ParserOptions {
        public function getMagicRFCLinks() {
                return $this->mMagicRFCLinks;
        }
+
+       /**
+        * @since 1.29
+        * @return bool
+        */
+       public function getAllowUnsafeRawHtml() {
+               return $this->allowUnsafeRawHtml;
+       }
+
+       /**
+        * Class to use to wrap output from Parser::parse()
+        * @since 1.30
+        * @return string|bool
+        */
+       public function getWrapOutputClass() {
+               $this->optionUsed( 'wrapclass' );
+               return $this->wrapOutputClass;
+       }
+
        public function setInterwikiMagic( $x ) {
                return wfSetVar( $this->mInterwikiMagic, $x );
        }
@@ -596,6 +636,28 @@ class ParserOptions {
                return wfSetVar( $this->mIsPrintable, $x );
        }
 
+       /**
+        * @param bool|null Value to set or null to get current value
+        * @return bool Current value for allowUnsafeRawHtml
+        * @since 1.29
+        */
+       public function setAllowUnsafeRawHtml( $x ) {
+               return wfSetVar( $this->allowUnsafeRawHtml, $x );
+       }
+
+       /**
+        * CSS class to use to wrap output from Parser::parse()
+        * @since 1.30
+        * @param string|bool $className Set false to disable wrapping.
+        * @return string|bool Current value
+        */
+       public function setWrapOutputClass( $className ) {
+               if ( $className === true ) { // DWIM, they probably want the default class name
+                       $className = 'mw-parser-output';
+               }
+               return wfSetVar( $this->wrapOutputClass, $className );
+       }
+
        /**
         * Set the redirect target.
         *
@@ -882,6 +944,10 @@ class ParserOptions {
                        $confstr .= '!printable=1';
                }
 
+               if ( $this->wrapOutputClass !== 'mw-parser-output' && in_array( 'wrapclass', $forOptions ) ) {
+                       $confstr .= '!wrapclass=' . $this->wrapOutputClass;
+               }
+
                if ( $this->mExtraKey != '' ) {
                        $confstr .= $this->mExtraKey;
                }