From: jenkins-bot Date: Wed, 8 Aug 2018 15:35:56 +0000 (+0000) Subject: Merge "LogFormatter: Fail softer when trying to link an invalid titles" X-Git-Tag: 1.34.0-rc.0~4521 X-Git-Url: http://git.cyclocoop.org//%22javascript:ModifierStyle%28%27%22.%24id.%22%27%29/%22?a=commitdiff_plain;h=e96b9055fbd4658087b99ef35f118bd618cafa26;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "LogFormatter: Fail softer when trying to link an invalid titles" --- e96b9055fbd4658087b99ef35f118bd618cafa26 diff --combined includes/logging/LogFormatter.php index 35bb45164d,1380ef8e0e..0e39b7ac97 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@@ -189,7 -189,6 +189,7 @@@ class LogFormatter * to avoid formatting for any particular user. * @see getActionText() * @return string Plain text + * @return-taint tainted */ public function getPlainActionText() { $this->plaintext = true; @@@ -437,8 -436,6 +437,8 @@@ /** * Gets the log action, including username. * @return string HTML + * phan-taint-check gets very confused by $this->plaintext, so disable. + * @return-taint onlysafefor_html */ public function getActionText() { if ( $this->canView( LogPage::DELETED_ACTION ) ) { @@@ -645,13 -642,18 +645,18 @@@ * @param Title|null $title The page * @param array $parameters Query parameters * @param string|null $html Linktext of the link as raw html - * @throws MWException * @return string */ protected function makePageLink( Title $title = null, $parameters = [], $html = null ) { if ( !$title instanceof Title ) { - throw new MWException( 'Expected title, got null' ); + $msg = $this->msg( 'invalidtitle' )->text(); + if ( !$this->plaintext ) { + return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ], $msg ); + } else { + return $msg; + } } + if ( !$this->plaintext ) { $html = $html !== null ? new HtmlArmor( $html ) : $html; $link = $this->getLinkRenderer()->makeLink( $title, $html, [], $parameters ); @@@ -705,7 -707,6 +710,7 @@@ * Helper method for displaying restricted element. * @param string $message * @return string HTML or wiki text + * @return-taint onlysafefor_html */ protected function getRestrictedElement( $message ) { if ( $this->plaintext ) { @@@ -741,12 -742,6 +746,12 @@@ return $this->context->msg( $key ); } + /** + * @param User $user + * @param int $toolFlags Combination of Linker::TOOL_LINKS_* flags + * @return string wikitext or html + * @return-taint onlysafefor_html + */ protected function makeUserLink( User $user, $toolFlags = 0 ) { if ( $this->plaintext ) { $element = $user->getName(); @@@ -948,10 -943,6 +953,10 @@@ class LegacyLogFormatter extends LogFor return $this->comment; } + /** + * @return string + * @return-taint onlysafefor_html + */ protected function getActionMessage() { $entry = $this->entry; $action = LogPage::actionText( diff --combined languages/i18n/en.json index 0948136f6b,50b85ef15a..caa22560f9 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@@ -376,6 -376,7 +376,7 @@@ "ns-specialprotected": "Special pages cannot be edited.", "titleprotected": "This title has been protected from creation by [[User:$1|$1]].\nThe reason given is $2.", "filereadonlyerror": "Unable to modify the file \"$1\" because the file repository \"$2\" is in read-only mode.\n\nThe system administrator who locked it offered this explanation: \"$3\".", + "invalidtitle": "Invalid title", "invalidtitle-knownnamespace": "Invalid title with namespace \"$2\" and text \"$3\"", "invalidtitle-unknownnamespace": "Invalid title with unknown namespace number $1 and text \"$2\"", "exception-nologin": "Not logged in", @@@ -2181,7 -2182,7 +2182,7 @@@ "categories": "Categories", "categories-summary": "", "categories-submit": "Show", - "categoriespagetext": "The following {{PLURAL:$1|category contains|categories contain}} pages or media.\n[[Special:UnusedCategories|Unused categories]] are not shown here.\nAlso see [[Special:WantedCategories|wanted categories]].", + "categoriespagetext": "The following {{PLURAL:$1|category exists|categories exist}} on the wiki, and may or may not be unused.\nAlso see [[Special:WantedCategories|wanted categories]].", "categoriesfrom": "Display categories starting at:", "deletedcontributions": "Deleted user contributions", "deletedcontributions-summary": "", diff --combined languages/i18n/qqq.json index 41765dfad9,d9bd995f15..4b1717d900 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@@ -576,6 -576,7 +576,7 @@@ "ns-specialprotected": "Error message displayed when trying to edit a page in the Special namespace", "titleprotected": "Used as error message. Parameters:\n* $1 - username; GENDER supported\n* $2 - reason for protection", "filereadonlyerror": "Parameters:\n* $1 - file name\n* $2 - file repository name\n* $3 - reason", + "invalidtitle": "Displayed when an invalid title was encountered (generally in a list) and there are no details about it to be shown.", "invalidtitle-knownnamespace": "Displayed when an invalid title was encountered (generally in a list), but the namespace number is known to exist.\n\nParameters:\n* $1 - (Unused) the namespace number\n* $2 - the namespace name in content language or {{msg-mw|blanknamespace}} for the main namespace\n* $3 - the part of the title after the namespace (e.g. SomeName for the page User:SomeName)", "invalidtitle-unknownnamespace": "Displayed when an invalid title was encountered (generally in a list) and the namespace number is unknown.\n\nParameters:\n* $1 - the namespace number\n* $2 - the part of the title after the namespace (e.g. SomeName for the page User:SomeName)", "exception-nologin": "Generic page title used on error page when a user is not logged in. Message used by the UserNotLoggedIn exception.\n{{Identical|Not logged in}}", @@@ -2381,7 -2382,7 +2382,7 @@@ "categories": "The page name of [[Special:Categories]].\n{{Identical|Category}}", "categories-summary": "{{doc-specialpagesummary|categories}}", "categories-submit": "Submit button on [[Special:Categories]]\n{{Identical|Show}}", - "categoriespagetext": "{{doc-important|Do not translate or change links.}}\nText displayed in [[Special:Categories]].\n\nIn order to translate \"Unused categories\" and \"wanted categories\" see {{msg-mw|Unusedcategories}} and {{msg-mw|Wantedcategories}}.\n\nParameters:\n* $1 - number of categories", + "categoriespagetext": "{{doc-important|Do not translate or change links.}}\nText displayed in [[Special:Categories]].\n\nIn order to translate \"wanted categories\" see {{msg-mw|Wantedcategories}}.\n\nParameters:\n* $1 - number of categories", "categoriesfrom": "Used as label for the input box in [[Special:Categories]].\n\nThis message follows the fieldset label {{msg-mw|categories}}, and is followed by the input box.", "deletedcontributions": "The message is shown as a link on [[Special:SpecialPages]] to [[Special:DeletedContributions]].\n\n{{Identical|Deleted user contributions}}", "deletedcontributions-summary": "{{doc-specialpagesummary|deletedcontributions}}",