cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ilya (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CB-3379) Incorrect way of trying to XHR the cordova_plugins.json file
Date Mon, 13 May 2013 14:09:17 GMT
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

Mime
View raw message