cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carl Peto" <carl_p...@dennis.co.uk>
Subject Proposed patch to prevent crash from malformed javascript in 2.4.0rc1
Date Wed, 06 Feb 2013 16:34:05 GMT

Dear Cordova,

We recently had a crash in iOS because we accidentally wrote this javascript…

Cordova.exec(frontPage.updatePublicationList,frontPage.Error,"MyPlugin","update-list", null);

I may have messed up the exact syntax during copy/paste/obfusticate but the essence is that
passing null for the parameters causes a crash. But it is perfectly understandable from a
javascript point of view, given that the method being called takes no parameters.

Cordova doesn't handle this well yet, at least on iOS.  Can I propose a small patch in the
iOS code to just defend against this?

diff --git a/CordovaLib/Classes/CDVInvokedUrlCommand.m b/CordovaLib/Classes/CDVInvokedUrlCommand.m
index 6c7a856..e3ca263 100644
--- a/CordovaLib/Classes/CDVInvokedUrlCommand.m
+++ b/CordovaLib/Classes/CDVInvokedUrlCommand.m
@@ -54,12 +54,14 @@
 {
     self = [super init];
     if (self != nil) {
-        _arguments = arguments;
+        if ([arguments isKindOfClass:[NSArray class]]) {
+            _arguments = arguments;
+            [self massageArguments];
+        }
         _callbackId = callbackId;
         _className = className;
         _methodName = methodName;
     }
-    [self massageArguments];
     return self;
 }


Thanks and regards.

Carl Peto,
Dennis Publishing

NOTE: The information in this email is confidential and may be legally
privileged, unless stated to the contrary. If you are not the intended recipient, you must
not read, use or disseminate that information.
Any opinions or comments are personal to the writer and do not represent the
official view of Dennis Publishing Ltd. If you have received this email and are not a named
addressee, please contact it.director@dennis.co.uk immediately by reply email and then delete
this message from your system. Please do not copy it or use it for any purpose, or disclose
its contents to any other person.
Although this email and any attachments are believed to be free of any virus, or other defects,
it is the responsibility of the recipient to ensure that they are virus free and no responsibility
is accepted by Dennis Publishing Ltd for any loss or damage arising from the receipt or use
thereof.
Company registered in England No. 1138891 
Registered office: 30, Cleveland Street, London, W1T 4JD



Mime
  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message