Translation mechanism fails for language codes with dashes

Bug #327450 reported by Rainer
4
Affects Status Importance Assigned to Milestone
Wikia Search UI
New
Undecided
Unassigned

Bug Description

When I select language "de-formal" ("Sie-Form"), the translation table can not be loaded because of the following JavaScript error:

Error: invalid assignment left-hand side
Source File: http://search.wikia.com/index.php?action=ajax&rs=wfGetJsTranslation&rsargs[]=de-formal&rsargs[]=1&random=0.7699519044452258
Line: 1, Column: 14
Source Code:
i18n.de-formal={"_LANGUAGE":"_LANGUAGE","Recent Changes":"Recent Changes", ... }

On the left-hand side of the assignment, the language code ("de-formal") needs to be quoted in order to be used as a lookup key.

In the trunk code, http://trac.wikia-code.com/browser/wikia/trunk/extensions/wikia/JSONProfile/i18nJSON_Ajax.php
the assignment above is generated on line 23.
There is a set of braces where I don't expect one, but those are apparently PHP syntax.

My suggestion for line 23 is this:
$text = "i18n.['{$lang}']= {$json};";

In the long run, I would prefer it if the MediaWiki extension did not have to know the variable name on the browser side.
Even better would be if the browser did not have to trust the MediaWiki side to issue benign expressions.
MediaWiki should just serve a JSON object. Yeah, I know, it's hard to do because of XSS safeguards.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.