Page MenuHomePhabricator

Apostrophe in linktrail breaks bolded links
Open, LowPublicFeature

Description

ca and kaa had an apostrophe (') in their linktrail. In 1.16 this worked fine, in 1.17 this caused things like '''[[Foo]]''' to be interpreted as '''[[Foo|Foo''']], which renders the apostrophes as literal characters in the link text and bolds the rest of the line. In other words, link trail processing seems to be done before triple apostrophe processing rather than after.


Version: unspecified
Severity: enhancement

Event Timeline

bzimport raised the priority of this task from to High.Nov 21 2014, 11:21 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz27473.

The parse order has changed for good reason. The simple way to fix this is to make the link trail regex not match two apostrophes in a row, with something like:

/ [a-z]* ( ' [a-z]* )? /

The complex way to fix it is to implement the same logic in Linker::splitTrail(), so that it works regardless of what the link trail regex is set to.

Proposed fix: Check for double apostrophe in Linker::splitTrail()

Unless I'm missing something, the fix is fairly simple. Search for '' in the link trail and put it outside of the link, if found. Only adds one strpos call per link, so it shouldn't add much processing time, either.

Parser tests still missing, though. I wasn't sure if we can make them dependent on a certain linktail regex.

Attached:

Alternative fix: Modify Ca and Kaa linktrail

Patch for changing the linktrail in the messages file. The linktrail is not NS_MEDIAWIKI customizable, so we have full control to make them match the current code.

I am using a negative lookahead instead of duplicating the rest of the linktrail.

Attached:

I've committed the fix for the ca & kaa linktrails as r85573, including parser test cases and a fix to Linker::splitTrail() for a bug that caused it to fail to actually test linktrails properly when $wgContLang changes over the course of a run.

For the moment I think I prefer the alt linktrails to the explicit check in splitTrail. Longer term we should consider a genericization of linktrails so we don't need the language-specific checks though, and should then consider apostrophes more generally if they're needed.

This comment was removed by jeblad.
This comment was removed by jeblad.

Change 278449 had a related patch set uploaded (by Stigmj):
If there are two or more apostrophes in a row in the linktrail, put them outside the link. This should be handled here due to separation of language and wikitext parsing.

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

Stigmj subscribed.

I have reintroduced the patch as proposed by P.Copp in 2011 as this seems to be a better solution to the problem. Please see T130451 for more justification.

Aklapper lowered the priority of this task from High to Low.
Aklapper added a subscriber: brion.
Stigmj raised the priority of this task from Low to Medium.May 30 2016, 5:28 PM

Why was the task reprioritized to "low"? On what grounds? We have a legitimate need to get this fixed, and the old "workaround" was just that, a workaround and performed in 2011.

Aklapper lowered the priority of this task from Medium to Low.Feb 3 2022, 11:20 AM
Aklapper edited projects, added Patch-Needs-Improvement; removed Patch-For-Review.
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:00 AM

Change 820739 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/core@master] Fix failing parser test because of translatewiki edit

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

Change 820739 abandoned by Thiemo Kreuz (WMDE):

[mediawiki/core@master] Fix failing parser test because of translatewiki edit

Reason:

Duplicate of Id40ffd5.

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