Page MenuHomePhabricator

Mixed use of RTL and LTR script with titles and usernames in a single line without isolation produce incorrect arrangement
Open, Needs TriagePublic

Description

See this link. The source written in the section was ":Yes, please read their constitution: [[s:ar:دستور سوريا]]. --[[Special:Contributions/60.26.9.220|60.26.9.220]] 08:38, 3 April 2019 (UTC)", however in my browser (Chrome) it was rendered as like this.

Event Timeline

C933103 created this task.Apr 6 2019, 7:39 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 6 2019, 7:39 AM
C933103 updated the task description. (Show Details)Apr 6 2019, 7:40 AM
Amire80 renamed this task from Mixed Use of RTL and LTR script in a single line produce incorrect arrangmenet. to Mixed use of RTL and LTR script with titles and usernames in a single line without isolation produce incorrect arrangement.Apr 6 2019, 8:06 AM
Amire80 added a subscriber: Amire80.Apr 6 2019, 8:17 AM

This happens because the Unicode bidi algorithm tries to re-arrange numbers and letters from different alphabets and cannot guess the user's intention correctly. This is especially common on MediaWiki sites with page titles, usernames, and IP addresses.

In this particular case, when editing in wiki syntax, the Arabic title is separated from the IP address numbers by "Special:Contributions" so it looks correct (to people who are accustomed to reading a lot of wiki syntax), but when the page is rendered in HTML, the numbers immediately follow the Arabic letters, so they jump to the wrong side of the page title.

Ideally, all page titles, usernames, and IP addresses should be bidi-isolated using the <bdi> tag or CSS such as unicode-bidi: isolate (more robust and semantic, but may have compatibility issues) or display: inline-block (more compatible, but less semantic and may have other issues). Since links, by their nature, usually point to titles and user names, this should be applied to links.

Until this bug is resolved comprehensively by applying it consistently everywhere, I can recommend applying the solutions above in templates that mention usernames or page titles, and to add <span dir="rtl">title</span> or <bdi>title</bdi> when mentioning RTL page titles in LTR wikis (and vice versa).