Merge "Fix some warnings from phan-taint-check"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 30 Aug 2018 02:54:03 +0000 (02:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 30 Aug 2018 02:54:03 +0000 (02:54 +0000)
1  2 
includes/EditPage.php
includes/htmlform/HTMLFormField.php

diff --combined includes/EditPage.php
@@@ -684,10 -684,7 +684,10 @@@ class EditPage 
                # checking, etc.
                if ( 'initial' == $this->formtype || $this->firsttime ) {
                        if ( $this->initialiseForm() === false ) {
 -                              $this->noSuchSectionPage();
 +                              $out = $this->context->getOutput();
 +                              if ( $out->getRedirect() === '' ) { // mcrundo hack redirects, don't override it
 +                                      $this->noSuchSectionPage();
 +                              }
                                return;
                        }
  
                                $this->sectiontitle = $request->getVal( 'preloadtitle' );
                                // Once wpSummary isn't being use for setting section titles, we should delete this.
                                $this->summary = $request->getVal( 'preloadtitle' );
 -                      } elseif ( $this->section != 'new' && $request->getVal( 'summary' ) ) {
 +                      } elseif ( $this->section != 'new' && $request->getVal( 'summary' ) !== '' ) {
                                $this->summary = $request->getText( 'summary' );
                                if ( $this->summary !== '' ) {
                                        $this->hasPresetSummary = true;
                                                !$oldrev->isDeleted( Revision::DELETED_TEXT )
                                        ) {
                                                if ( WikiPage::hasDifferencesOutsideMainSlot( $undorev, $oldrev ) ) {
 -                                                      // Cannot yet undo edits that involve anything other the main slot.
 -                                                      $undoMsg = 'main-slot-only';
 +                                                      // Hack for undo while EditPage can't handle multi-slot editing
 +                                                      $this->context->getOutput()->redirect( $this->mTitle->getFullURL( [
 +                                                              'action' => 'mcrundo',
 +                                                              'undo' => $undo,
 +                                                              'undoafter' => $undoafter,
 +                                                      ] ) );
 +                                                      return false;
                                                } else {
                                                        $content = $this->page->getUndoContent( $undorev, $oldrev );
  
@@@ -1782,7 -1774,7 +1782,7 @@@ ERROR
                        if ( $this->summary === '' ) {
                                $cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle );
                                return $this->context->msg( 'newsectionsummary' )
-                                       ->rawParams( $cleanSectionTitle )->inContentLanguage()->text();
+                                       ->plaintextParams( $cleanSectionTitle )->inContentLanguage()->text();
                        }
                } elseif ( $this->summary !== '' ) {
                        $sectionanchor = $this->guessSectionName( $this->summary );
                        # in the revision summary.
                        $cleanSummary = $wgParser->stripSectionName( $this->summary );
                        return $this->context->msg( 'newsectionsummary' )
-                               ->rawParams( $cleanSummary )->inContentLanguage()->text();
+                               ->plaintextParams( $cleanSummary )->inContentLanguage()->text();
                }
                return $this->summary;
        }
                        $this->autoSumm = md5( '' );
                }
  
 -              $autosumm = $this->autoSumm ?: md5( $this->summary );
 +              $autosumm = $this->autoSumm !== '' ? $this->autoSumm : md5( $this->summary );
                $out->addHTML( Html::hidden( 'wpAutoSummary', $autosumm ) );
  
                $out->addHTML( Html::hidden( 'oldid', $this->oldid ) );
        }
  
        /**
 -       * Helper function for summary input functions, which returns the neccessary
 +       * Helper function for summary input functions, which returns the necessary
         * attributes for the input.
         *
         * @param array|null $inputAttrs Array of attrs to use on the input
@@@ -462,16 -462,6 +462,16 @@@ abstract class HTMLFormField 
                if ( isset( $params['hide-if'] ) ) {
                        $this->mHideIf = $params['hide-if'];
                }
 +
 +              if ( isset( $this->mParams['notice-message'] ) ) {
 +                      wfDeprecated( "'notice-message' parameter in HTMLForm", '1.32' );
 +              }
 +              if ( isset( $this->mParams['notice-messages'] ) ) {
 +                      wfDeprecated( "'notice-messages' parameter in HTMLForm", '1.32' );
 +              }
 +              if ( isset( $this->mParams['notice'] ) ) {
 +                      wfDeprecated( "'notice' parameter in HTMLForm", '1.32' );
 +              }
        }
  
        /**
                        $error = new OOUI\HtmlSnippet( $error );
                }
  
 -              $notices = $this->getNotices();
 +              $notices = $this->getNotices( 'skip deprecation' );
                foreach ( $notices as &$notice ) {
                        $notice = new OOUI\HtmlSnippet( $notice );
                }
                        'errors' => $errors,
                        'notices' => $notices,
                        'infusable' => $infusable,
 +                      'helpInline' => $this->isHelpInline(),
                ];
  
                $preloadModules = false;
         * @return bool
         */
        protected function shouldInfuseOOUI() {
 -              // Always infuse fields with help text, since the interface for it is nicer with JS
 -              return $this->getHelpText() !== null;
 +              // Always infuse fields with popup help text, since the interface for it is nicer with JS
 +              return $this->getHelpText() !== null && !$this->isHelpInline();
        }
  
        /**
                return $helptext;
        }
  
 +      /**
 +       * Determine if the help text should be displayed inline.
 +       *
 +       * Only applies to OOUI forms.
 +       *
 +       * @since 1.31
 +       * @return bool
 +       */
 +      public function isHelpInline() {
 +              return isset( $this->mParams['help-inline'] ) ? $this->mParams['help-inline'] : true;
 +      }
 +
        /**
         * Determine form errors to display and their classes
         * @since 1.20
         *
+        * phan-taint-check gets confused with returning both classes
+        * and errors and thinks double escaping is happening, so specify
+        * that return value has no taint.
+        *
         * @param string $value The value of the input
         * @return array array( $errors, $errorClass )
+        * @return-taint none
         */
        public function getErrorsAndErrorClass( $value ) {
                $errors = $this->validate( $value, $this->mParent->mFieldData );
         * Determine notices to display for the field.
         *
         * @since 1.28
 +       * @deprecated since 1.32
 +       * @param string $skipDeprecation Pass 'skip deprecation' to avoid the deprecation
 +       *   warning (since 1.32)
         * @return string[]
         */
 -      public function getNotices() {
 +      public function getNotices( $skipDeprecation = null ) {
 +              if ( $skipDeprecation !== 'skip deprecation' ) {
 +                      wfDeprecated( __METHOD__, '1.32' );
 +              }
 +
                $notices = [];
  
                if ( isset( $this->mParams['notice-message'] ) ) {
         * Formats one or more errors as accepted by field validation-callback.
         *
         * @param string|Message|array $errors Array of strings or Message instances
+        * To work around limitations in phan-taint-check the calling
+        * class has taintedness disabled. So instead we pretend that
+        * this method outputs html, since the result is eventually
+        * outputted anyways without escaping and this allows us to verify
+        * stuff is safe even though the caller has taintedness cleared.
+        * @param-taint $errors exec_html
         * @return string HTML
         * @since 1.18
         */