Page MenuHomePhabricator

Localized brackets can break accesskey handling
Closed, ResolvedPublic

Description

Since gerrit 90892 the [] for accesskeys are used from message 'brackets', when using other brackets (like '()') there, the regex in module jquery.accessKeyLabel gets not matched, because the [] are hard coded. Same for the word-seperator, when no space is used the regex will also not match:

oldTitle.replace( / \[.*?\]$/, '' )

After fix of bug 48505 there are now two accesskey hints. The default accesskey hint and one with [] and the right buttons (like alt or ctrl), because it is always added.


Version: 1.24rc
Severity: normal

Details

Reference
bz65010

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:25 AM
bzimport set Reference to bz65010.

The hardcoded brackets and space is replaced in gerrit 132009, but I have no idea to build a safe regex from that messages.

Change 132009 had a related patch set uploaded by Gerrit Patch Uploader:
jquery.accessKeyLabel: Replace hardcoded brackets and space

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

(In reply to Umherirrender from comment #1)

I have no idea to build a safe regex from that messages.

It might be easier to just cache the original tooltips somewhere and do away with the regex entirely. We'd just have to be extra careful about being compatible with dynamically changing tooltips (like in mediawiki.page.watch.ajax.js).

Maybe we could use jQuery attr hooks for this? http://blog.rodneyrehm.de/archives/11-jQuery-Hooks.html (Just a thought, I didn't look into this in detail.)

The original tooltip is the tooltip from PHP. This contains title text and the access key text at the end for compatibility with clients without JavaScript. Without regex the title text has to transfered on a alternative way to JavaScript. mediawiki.page.watch.ajax.js has this because it changes the title text. When a script changes only the access key and without changing the title text the title text is normally not available and the regex is necessary to extract the title text from the tooltip.

attr hook seams to be a good idea.

Change 132009 merged by jenkins-bot:
jquery.accessKeyLabel: Replace hardcoded brackets and space

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

Was successfully merged

(In reply to Bartosz Dziewoński from comment #3)

Maybe we could use jQuery attr hooks for this?
http://blog.rodneyrehm.de/archives/11-jQuery-Hooks.html (Just a thought, I
didn't look into this in detail.)

The MutationObserver would also be a possible solution. [1] [2]
This should even work when the attributes get changed without jQuery.
But it is not supported by IE < 11. [3]

[1] http://www.w3.org/TR/dom/#interface-mutationobserver
[2] https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
[3] http://caniuse.com/#feat=mutationobserver