Page MenuHomePhabricator

Recent replaceInternalLinks() patch causes line breaks to be stripped from an internal link following a category
Closed, ResolvedPublic

Description

@Danny_B reported vertical whitespace changes in {{Denní přehled}} on cs.wiktionary.org, e.g. https://cs.wikinews.org/wiki/30._srpen_2017 . Investigation showed that rtrim( $trail, "\n" ) in https://gerrit.wikimedia.org/r/#/c/371735 (for T87753) causes line breaks to be stripped from the following internal link, wherever that is. For example:

> print $wgParser->replaceInternalLinks("[[Category:Foo]]<div>a\n\n[[Foo]]</div>");
<div>a<!--LINK 0:1--></div>
> print $wgParser->parse("[[Category:Foo]]<div>a\n\n[[Foo]]</div>", $t, $o)->getText(); 
<div class="mw-parser-output"><div>a<a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">Foo</a></div>

This is because $trail extends to the start of the next link. Running rtrim() on it makes no apparent sense.

Event Timeline

Change 375095 had a related patch set uploaded (by Legoktm; owner: Tim Starling):
[mediawiki/core@master] Revert "Fix link prefix/suffixes around Category and Language links."

https://gerrit.wikimedia.org/r/375095

Change 375095 merged by jenkins-bot:
[mediawiki/core@master] Revert "Fix link prefix/suffixes around Category and Language links."

https://gerrit.wikimedia.org/r/375095

Reverted, cherry picked and deployed

Change 376441 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/core@master] [WIP] Fix link prefix/suffixes around Category and Language links (take 2).

https://gerrit.wikimedia.org/r/376441

Change 376441 merged by jenkins-bot:
[mediawiki/core@master] Fix link prefix/suffixes around Category and Language links (take 2).

https://gerrit.wikimedia.org/r/376441