You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Ilya (JIRA)" <ji...@apache.org> on 2013/05/13 16:09:17 UTC

[jira] [Created] (CB-3379) Incorrect way of trying to XHR the cordova_plugins.json file

Ilya created CB-3379:
------------------------

             Summary: Incorrect way of trying to XHR the cordova_plugins.json file 
                 Key: CB-3379
                 URL: https://issues.apache.org/jira/browse/CB-3379
             Project: Apache Cordova
          Issue Type: Bug
          Components: Android
    Affects Versions: 2.7.0
            Reporter: Ilya
            Assignee: Joe Bowser


Frankly, I don't like the way you are trying to XHR the cordova_plugins.json file asynchronously (*lines 6811-6831 in cordova-2.7.0.js*).
Why there is no check:

{code:title=cordova-2.7.0.js|borderStyle=solid}
  xhr.onload = function() {
    if (xhr.readyState === 4) {
      if (xhr.status === 200) {
        ....
        handlePluginsObject(obj);
      } else {
        finishPluginLoading();
      }
    }
  }
   ....
{code}

For instance, if there is no cordova_plugins.json jetty server will send a responce with the following responceText:


{code:xml} 
"<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 404 Not Found</title>
</head>
<body>
<h2>HTTP ERROR: 404</h2>
<p>Problem accessing /cordova_plugins.json. Reason:
<pre>    Not Found</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>"
{code}     

And JSON.parse will throw "*SyntaxError: Unexpected token <*", which won't be caught - app will crash                                 

 



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira