Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-10964

Handle build.json file starting with a BOM

    XMLWordPrintableJSON

Details

    Description

      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", use the following line
      ....
      var config = JSON.parse(buildjson.replace(/^\uFEFF/, ''));
      ...
      instead of
      ....
      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.

      Attachments

        Activity

          People

            daserge Sergey Shakhnazarov
            sqying Shuqian Ying
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: