Opened 13 years ago

Last modified 13 years ago

#6885 closed defect

ShrinkSafe fail when "dojo.requireLocalization" arguments aren't a string constant because ShrinkSafe execute eval instruction to get string value — at Version 1

Reported by: harobed Owned by: alex
Priority: high Milestone:
Component: BuildSystem Version: 1.1.0
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by harobed)

I've this code :

try {
    Node.innerHTML = code.replace(reg,function(o,a,b) {
        if (!window[a]) { //unknown localization module?
            window[a] = dojo.i18n.getLocalization("i18n", a.substring(2,64).toLowerCase());
        var sRes = (window[a])[b] || "";
        return sRes.replace(/\\n/g,"<br>");
} catch(e) {
    console.error("Error in translateApp:",e.message);

ShrinkSafe? raise this error :

release:  Interning strings for file: ../../release/dojo/dojo/dojo.js
release:  Optimizing (shrinksafe) file: ../../release/dojo/dojo/dojo.js
js: "jslib/i18nUtil.js#64(eval)", line 1: uncaught JavaScript runtime exception: ReferenceError: "a" is not defined.

I've look in dojo/util/buildscripts/jslib/i18nUtil.js

62  var requireStatements = fileContents.match(/dojo\.requireLocalization\(.*\)\;/g);
63  if(requireStatements){	
64      eval(requireStatements.join(";"));
66      //print("loaded bundles: "+djLoadedBundles.length);
68      var djBundlesByLocale = {};
69      var jsLocale, entry, bundle;
71      ...

ShrinkSafe? extract and eval all "requireLocalization" to get the ressource file name. In my instance, requireLocalization bundleName parameter isn't a constant but one variable then the string extracted can't be process by "eval" instruction.

I've write a patch to fix issue.

Change History (2)

Changed 13 years ago by harobed

Attachment: i18nUtil.js.patch added

i18nUtil.js patch

comment:1 Changed 13 years ago by harobed

Description: modified (diff)
Note: See TracTickets for help on using tickets.