Page MenuHomePhabricator

Apostrophe in linktrail breaks bolded links
Open, MediumPublic


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.
Catrope created this task.Feb 16 2011, 8:38 PM

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.


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.


brion added a comment.Apr 6 2011, 9:14 PM

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.

brion added a comment.Apr 6 2011, 9:18 PM

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.

jeblad added a subscriber: jeblad.Mar 19 2016, 2:03 PM
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.

Stigmj reopened this task as Open.Mar 19 2016, 2:55 PM
Stigmj added a subscriber: Stigmj.

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.

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 19 2016, 2:55 PM
Aklapper removed brion as the assignee of this task.Mar 19 2016, 4:08 PM
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.

Priority reflects the reality. But as you provided (thanks!) it makes sense to raise priority - thanks!