EditPage: Disable preview on open if $wgRawHtml is enabled
authorKunal Mehta <legoktm@member.fsf.org>
Sat, 23 Sep 2017 21:07:15 +0000 (14:07 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Sat, 23 Sep 2017 21:07:15 +0000 (14:07 -0700)
Otherwise the user will see a session failure message since their
request wasn't posted with a token, which doesn't make sense since they
just clicked on an edit link.

Bug: T172251
Change-Id: Id4a20818c737886f5a7ec72dba52c531f1ba78a0

includes/EditPage.php

index aa1f205..b499d96 100644 (file)
@@ -821,8 +821,15 @@ class EditPage {
         * @return bool
         */
        protected function previewOnOpen() {
-               $previewOnOpenNamespaces = $this->context->getConfig()->get( 'PreviewOnOpenNamespaces' );
+               $config = $this->context->getConfig();
+               $previewOnOpenNamespaces = $config->get( 'PreviewOnOpenNamespaces' );
                $request = $this->context->getRequest();
+               if ( $config->get( 'RawHtml' ) ) {
+                       // If raw HTML is enabled, disable preview on open
+                       // since it has to be posted with a token for
+                       // security reasons
+                       return false;
+               }
                if ( $request->getVal( 'preview' ) == 'yes' ) {
                        // Explicit override from request
                        return true;