Last modified: 2012-10-08 21:16:33 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T33817, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 31817 - The <bdi> tag is sanitized
The <bdi> tag is sanitized
Status: VERIFIED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Amir E. Aharoni
:
Depends on: 39525
Blocks: rtl
  Show dependency treegraph
 
Reported: 2011-10-19 10:28 UTC by Amir E. Aharoni
Modified: 2012-10-08 21:16 UTC (History)
10 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
A demo of possible use cases for the <bdi> tag. (1.06 KB, text/html)
2011-10-20 17:56 UTC, Amir E. Aharoni
Details

Description Amir E. Aharoni 2011-10-19 10:28:20 UTC
HTML5 has several new features designed to help web designers create pages that show RTL text properly. Among them is the new <bdi> element. It stands for "bi-directional isolation", and it basically means that the text inside it doesn't mix up with adjacent punctuation marks and numbers, which have ambiguous directionality properties.

When it will be widely supported in browsers, this element will become very useful in Wikimedia projects. Probably the most common use case for it is showing the left-to-right name in an article about a person in a right-to-left Wikipedia; this name is usually written in the opening paragraph and adjacent to the birth date, which consists of numbers that get mixed up because of the bidi algorithm. Currently it is solved by using Unicode control characters (RLM), <bdi> is a more elegant solution.

This tag is currently sanitized, so it is impossible to use it in MediaWiki pages. It shouldn't be sanitized. To do this, i suppose that it should be added to htmlpairsStatic in includes/Sanitizer.php, but i'm not so familiar with that class, so maybe something else is needed.

When will it be widely supported in browsers? It was just added to Mozilla, and note that even the source file name is similar:
https://hg.mozilla.org/mozilla-central/rev/6f03f6a821c0

AFAIK, it is also about to be added to Chrome.
Comment 1 Brion Vibber 2011-10-19 18:14:09 UTC
Damn, that sounds like it'll actually be useful. Wish we had it in HTML 4! ;)

http://dev.w3.org/html5/spec/text-level-semantics.html#the-bdi-element

Once we pass it through, is there any CSS we could do to simulate it on existing browsers that wouldn't interfere (like unicode-bidi: embed? or would that also require explicitly knowing what direction to add), or would it just have to be a progressive enhancement?
Comment 2 Amir E. Aharoni 2011-10-19 19:13:42 UTC
I'm not sure that there's a proper way to simulate it, except maybe trying to play with RLMs. I'm going to try to build a template that does something like it, but i can't promise anything.
Comment 3 Amir E. Aharoni 2011-10-20 17:56:11 UTC
Created attachment 9262 [details]
A demo of possible use cases for the <bdi> tag.

The attachment gives a couple of use cases for the <bdi> tag. Both can use the RLM character instead, but <bdi> is more elegant.

You can test it in the Mozilla Nightly version that was published today. Fresh!
Comment 4 Siebrand Mazeland 2012-01-23 13:45:57 UTC
Untagging milestone 1.19. This has not been resolved, and trunk is closed to new features for 1.19.
Comment 5 Santhosh Thottingal 2012-02-07 05:45:41 UTC
Firefox 10 has this feature released. https://developer.mozilla.org/en/Firefox_10_for_developers 

"The new HTML5 <bdi> element, bi-directional isolation, allowing isolation of parts of text with a different directionality has been implemented."
Comment 6 Amir E. Aharoni 2012-03-05 12:18:18 UTC
(In reply to comment #1)
> Damn, that sounds like it'll actually be useful. Wish we had it in HTML 4! ;)
> 
> http://dev.w3.org/html5/spec/text-level-semantics.html#the-bdi-element
> 
> Once we pass it through, is there any CSS we could do to simulate it on
> existing browsers that wouldn't interfere (like unicode-bidi: embed? or would
> that also require explicitly knowing what direction to add), or would it just
> have to be a progressive enhancement?

There's no perfect way to emulate it, but this shouldn't be the reason for not enabling <bdi> now at least to start testing it in some less-essential environments where failures on older browsers won't be too harmful.
Comment 7 Amir E. Aharoni 2012-03-28 06:45:32 UTC
Fix committed in https://gerrit.wikimedia.org/r/#change,3844 , please review.
Comment 8 Brion Vibber 2012-04-04 20:22:32 UTC
Reviewed, added parser test case, added to attribute whitelist to ensure that 'lang' attribute works, and merged.

https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=commit;h=fe0b0270fdb242c1aed6b39c1be4782792f323a5
Comment 9 Amir E. Aharoni 2012-05-13 05:49:32 UTC
The fix appears to be merged and deployed. It works as I expect on my local test wiki. But if I try it on the English Wikipedia, the <bdi> tag disappears completely.

See an example here:
https://en.wikipedia.org/wiki/User:Amire80/bdi

Before the fix the tag would appear escaped, so you would just see the <bdi>text</bdi> in the rendered page. Now it seems to disappear. When I look at the source of the rendered page, I see:

The Hebrew name of Haifa is חיפה.<sup id="cite_ref-0" class="reference"><a href="#cite_note-0"><span>[</span>1<span>]</span></a></sup>

On my local wiki I see: The Hebrew name of Haifa is חיפה.<bdi><sup id="cite_ref-0" class="reference"><a href="#cite_note-0">[1]</a></sup></bdi>
Comment 10 Krinkle 2012-05-14 09:11:49 UTC
I thought maybe it wasn't working on en.wikipedia.org due to wgHtml5=false there. But tested on mediawiki.org (where wgHtml5=true) and there it doesn't work either:

https://www.mediawiki.org/w/index.php?title=Project:Sandbox&oldid=537524

<bdi> is tripped.

Maybe caused by W3 Tidy ?
Comment 11 Derk-Jan Hartman 2012-08-01 10:30:36 UTC
It works on the foundation wiki
(i used http://wikimediafoundation.org/wiki/Special:ExpandTemplates, since i'm no editor there)

which has Tidy disabled, so could be Tidy indeed.
Comment 12 Derk-Jan Hartman 2012-08-01 10:36:18 UTC
We need to upgrade tidy to a version that knows about the latests html5 tricks.

In the mean time, we can adapt the config of Tidy by adding "new-inline-tags: bdi" to it.
Comment 13 Derk-Jan Hartman 2012-08-01 10:58:02 UTC
https://gerrit.wikimedia.org/r/17174

Added the bdi element to the Tidy configuration that ships with MediaWiki. No idea if that is actually the one we use on WMF sites however. There seems to be no tidy config in our puppet repo at least.
Comment 14 matanya 2012-08-14 12:05:19 UTC
patch moved to gerrit. removing patch-need-review key word
Comment 15 Derk-Jan Hartman 2012-08-23 21:03:09 UTC
patch merged.
Comment 16 Amir E. Aharoni 2012-09-04 11:41:59 UTC
I confirm that Derk-Jan's patch does the right thing.
Comment 17 Amir E. Aharoni 2012-10-08 21:16:33 UTC
Works on Wikipedia.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links