You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Shuqian Ying (JIRA)" <ji...@apache.org> on 2016/03/25 22:15:25 UTC

[jira] [Created] (CB-10964) build.js script under "platforms\android\cordova\lib" can not handle build.json file starting with a BOM

Shuqian Ying created CB-10964:
---------------------------------

             Summary: build.js script under "platforms\android\cordova\lib" can not handle build.json file starting with a BOM
                 Key: CB-10964
                 URL: https://issues.apache.org/jira/browse/CB-10964
             Project: Apache Cordova
          Issue Type: Bug
          Components: CLI
    Affects Versions: 3.5.0
         Environment: All development platforms
            Reporter: Shuqian Ying
            Priority: Blocker


The generated build.js file under the "platforms\android\cordova\lib" directory of a project throws exceptions when reading the utf-8 encoded build.json file under the root directory of the same project that starts with a byte order mark (BOM), due to a bug/feature of the Javascript JSON.parse method. Such kind of files are normally generated in automated build systems, like ours.

The solution we found is to strip that mark before parsing, namely, inside of the function "parseOpts", add the following line

var buildjson = fs.readFileSync(buildConfig, 'utf8');
....
var config = JSON.parse(buildjson.replace(/^\uFEFF/, ''));

instead of 

var buildjson = fs.readFileSync(buildConfig, 'utf8');
....
var config = JSON.parse(buildjson);


This has always been a problem up to the most recent stable version (3.5.0) and most likely to cause the same problem for other platforms, besides android.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org