Post I5039c7ef9e07199c256fd568b4f94714e5831d17, gallery image captions
are no longer placed on new lines, so the presence of leading whitespace
shouldn't be significant.
This fixes an inconsistency in gallery image caption trimming, where
only the first and last option had start and end trimming, respectively.
It also matches Parsoid output, where no trimming takes places, as seen
in the updated tests.
Change-Id: I2a80198c43598dc8c7fa61cb4b0340a97d2ee895
Changes to the use statements done automatically via script
Addition of missing use statement done manually
Change-Id: Ia35b2d3105880631dd26ec974068b000ac7f4b6b
I60fdfc2c52 changed replaceTableOfContentsMarker from using
preg_replace, which supports backreferences in the replacement, and
thus expects literal backslashes and dollar signs to to be escaped,
to using preg_replace_callback, which does not expect any escaping.
This caused unwanted backslashes in headings. This patch removes the
escaping.
Bug: T365413
Change-Id: Idbdc3074c7ad007627c4c259a1aaf090a5d0c7f9
Move Linker::makeExternalLink to the LinkRenderer service, as has been
done with the other static methods of Linker.
In order to allow phan's SecurityCheckPlugin to perform a more accurate
analysis of taintedness, tweak the API of Linker::makeExternalLink to
clearly indicate via the type system whether the link text has already
been escaped or not: a `string` argument will always be escaped, and
if the argument is already escaped it should be passed as an HtmlArmor
object. In refactoring, `Message` arguments were also common, and accept
them as-is to avoid the caller having to think about whether to call
Message::text() or Message::escaped().
This allows us to provide a more precise taint type to the $text argument,
avoids an opaque boolean argument, and avoids spurious errors from
SecurityCheck.
We also require the caller to explicitly pass a Title context, instead
of implicitly relying on the global $wgTitle. This works cleanly
everywhere except for CommentParser, which has a $selfLinkTarget which
generally works as the title context for the external link, but which
is nullable. The original Linker::makeExternalLink() used $wgTitle as
a fallback, but $wgTitle can also be null in some circumstances. The
title context only determines how $wgNoFollowNsExceptions is handled,
so existing code basically just ignored $wgNoFollowNsExceptions when
$wgTitle was null, which isn't terrible. A future refactor could/should
clean up CommentParser to ensure that there is always a non-null title
context that can be used.
Change-Id: I9bcf4780f388ba639a9cc882dd9dd42eda5736ae
In some extensions they check that getOutput returns null
if it does they return early. For example:
https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/5579
But with the type change in I247643b9bf0cabdc92a7e893d653edeaed9a1307
(MW 1.41.0), that attempt fails with the following:
```
Error: Typed property Parser::$mOutput must not be accessed before initialization
```
Fix this by allowing Parser::getOutput() to return null,
but emit a deprecation warning to notify users that the
Parser object has not been property initialized at this
point.
Change-Id: I0de2cf0381ceac36374a47fb11e260b1c522353b
This patch introduces a namespace declaration for the
MediaWiki\Content to TextContent and establishes a class
alias marked as deprecated since version 1.43.
Bug: T353458
Change-Id: Ic251b1ddfcf6db9c85cb54cddf912aa827d2bc3a
This patch introduces a new namespace declaration,
MediaWiki\Xml and adds Xml and XmlSelect to it
and establishes class aliases marked as deprecated
since version 1.43.
Bug: T353458
Change-Id: I45cccd540b6e15f267d3ab588a064fbeb719d921
Add strict types to private parsing-related methods
OutputPage::parseInternal() and OutputPage::addWikiTextTitleInternal()
and in the process hoist the "null Titles are not allowed" assertion
up a level to the callers.
Adjust some phan suppressions after this change.
Change-Id: If828d9ffa1edc292a1aca3eb6fe36daffa100bd4
To display the names as they're used in wikitext, we must look up the
right syntax, as not all of them are prefixed with "#".
This also displays them in content language (not sure if that's good,
but if we want them to look like they're supposed to be used in
wikitext, I guess it is?), in the preferred case, and in the right
order (order of hooks like 'lc' and 'lcfirst' was previously
reversed, because the trailing '}}' was considered when sorting).
Follow-up to 9308818ee9.
Change-Id: Ia7c505e196e7ae28badc6314b2d6c91f8be45689
This patch introduces a namespace declaration for the
MediaWiki\Debug to DeprecationHelper and establishes a class
alias marked as deprecated since version 1.43.
Bug: T353458
Change-Id: I808c6aa7836445feaa7b401624d79d01f2c70322
The legacy parser only allows for a single insertion of TOC (it drops
later __TOC__ magic words). On Parsoid, we can end up with multiple TOC
markers (which we want to keep around for round-trip reasons), so we
need to discard them in the HandleTOCMarkers phase.
Bug: T359882
Change-Id: I60fdfc2c52680ed53e48d1931fd7f5c937b437a2
Fix the real issues found by this sniff, and convert the remaining
false positive ignores to per-line ignores so that any more real issues
won't be added.
Change-Id: I18e75d59df327e2d93a3a487c115e92b9f268722
We are deprecating dynamic properties on the Parser object, but as a
first step we're making them *actual* properties, so that we can draw
a line in the sand against adding new dynamic properties. In a follow
up we'll actually remove this property from the
LabeledSectionTransclusion extension.
An entry in RELEASE-NOTES-1.42 was already added in
Id3dbc99d92f2769d4e5c95293cf1a277b98ddd3b.
Bug: T362693
Bug: T343227
Bug: T362692
Followup-To: I701a27459704839f9f996a171b6982ed17cdd00b
Change-Id: I3a992f4d601135b6327d941a1852e861d1e82d78
We are deprecating dynamic properties on the Parser object, but as a first
step we're making them *actual* properties, so that we can draw a line in
the sand against adding new dynamic properties. In a follow up we'll
actually remove this property from the ProofreadPage extension.
Also add an entry to RELEASE-NOTES-1.42, which
Ifcb9492cc5c814d702c6e61e8231abfd8ea0647c forgot to include.
Bug: T362664
Bug: T343227
Followup-To: Ifcb9492cc5c814d702c6e61e8231abfd8ea0647c
Change-Id: Id3dbc99d92f2769d4e5c95293cf1a277b98ddd3b
Hack in declared public properties to work around T343229 (use in
Scribunto), T343230 (use in Cite), T343226 (use in TemplateStyles),
T203531 (use in Variables), T203532 (use in Arrays), T203563 (use
in Loops), T359887 (use in HashTables) and T357838 (use in parser
tests) for now, but we can draw a line in the sand and not allow
any further use of this pattern.
Bug: T343227
Depends-On: Ifcb9492cc5c814d702c6e61e8231abfd8ea0647c
Change-Id: I701a27459704839f9f996a171b6982ed17cdd00b
Remove dead code left over from the removal of the
BeforeParserFetchTemplateAndtitle (sic) hook in
20c5632c4e.
While we're at it, add test cases for statelessFetchTemplate and
improve coverage.
Followup-To: Ifecd4108eb02ebccc0c7bc4ec432036da08ffe53
Followup-To: Idf1fd12cc61ca30867dc9f8aeb1701fe035fc5ff
Change-Id: I135f5234e7be015a2781d6cb8d23b3143b618c5a
This follows up on I5e87b33a956e296cdaf671fa99c9555944b73479 and makes
(invisible) language links consistent with how we handle (invisible)
category links.
Bug: T359886
Followup-To: I5e87b33a956e296cdaf671fa99c9555944b73479
Change-Id: I3e5567a91b47e0b04da928450644f3f475aaf51b
This follows up on a long series of tweaks to whitespace handling around
[[Category]] links (T2087, T87753, T174639) which aimed to simplify and
make intelligible the whitespace handling around category links without
allowing categories to break lists or paragraphs in which they are found.
Removing newlines but not other whitespace on the left-hand side of
category links should preserve the valuable features of T2087 et al
while still ensuring that the following all render equivalently:
ABC [[Category:Foo]]DEF
ABC[[Category:Foo]] DEF
ABC [[Category:Foo]] DEF
Added parser test to document the new behavior; it's worth noting
that although there were plenty of tests documenting the expected
interaction of category links and newlines, there were previously
no tests covering the interaction of non-newline whitespace and
category links; the one test which needed to be altered added
non-semantic whitespace (ie, extra whitespace to the test output
which did not affect the way the HTML would display).
This patch brings the legacy parser into parity which Parsoid parsing
of category links.
Bug: T359886
Change-Id: I5e87b33a956e296cdaf671fa99c9555944b73479
This ensures uniform treatment of all places that call `addCategory`
without duplicating the `defaultsort` code; it also ensures that the
effect of the {{DEFAULTSORT}} parser function is independent of page
position.
Bug: T40435
Bug: T353530
Change-Id: I4480a6d59e766fa4eddc9ec9117c58b66771bb47
ParserOutput::getText() is not a simple getter, but does
transformations on the "text" of the ParserOutput; the simple getter
is named ::getRawText().
To maintain consistency, rename ParserOutput::setText() to
::setRawText() and the property name ParserOutput::$mText to
::$mRawText so future readers are not confused.
The JSON property name as it appears in the serialized ParserCache
is left as 'Text' so that we don't have any forward- or backward-
rollback issues.
Change-Id: I3ef34814ab9473cc70d0a6806e8c5a4a02b73491
[Previously attempted in de0646843a,
reverted in e72e1cd16368346b66853f68e2d13f9b416d5a11.]
Previously, Parser.php used Linker::makeHeadline() in order to
generate the `<h2><span class="mw-headline" id="...">...</span></h2>`
markup for section headings, and this was saved in the parser cache.
Now it generates heading tags with placeholder attributes like
`<h2 data-mw-...="..." ...>...</h2>`, and they are replaced in a
post-cache transform to generate the final heading markup, similarly
to how section edit links already worked.
The purpose of these changes is to allow changing the final markup
depending on skin options without splitting the parser cache (T13555).
Deployment and undeployment safety:
* The new post-cache transform has been already added in commit
Ibce512b3c4a52f74b2d2124f0159e306f2689ea5 for forward-compatibility
(so that if this patch is reverted, new parser cache entries
will still be shown correctly).
Implementation notes:
* There are many ways to keep the temporary information other than
`data-mw-...` attributes, but this way is the easiest to handle
in a post-cache transform (everything is on the DOM node we want
to modify), is compatible with other heading-enhancing code in
DiscussionTools and MobileFrontend, and remains human-readable
if the post-cache transform doesn't run.
* Sadly this code can't be reused to add section heading markup and
section edit links to Parsoid (T269630), because it lacks some of
the necessary metadata, and exposes the rest in ways that are
trickier to handle in a post-cache transform (on other DOM nodes
or outside the document).
Depends-On: If85f89c40834618f23dc0ace2e599efb3b6d5ed4
Bug: T13555
Change-Id: If04d72f427ec3c3730e757cbb3ade8840c09f7d3