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

nil callbackId in isValidCallbackId() causes regex match to throw exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.5.0
    • 3.6.0
    • cordova-ios
    • None
    • Mac OSX, XCode 5.1.1. iOS 6.1 on iphone. cordova cli.

    Description

      (to determine i'm using cordova lib 3.5.0, I ran <project_home>/platforms/ios/cordova/version)

      An exception is thrown at this line of code which causes my cordova app to stop. If I comment out this line of code, my app seems to run fun. The PushPlugin seems to pass in a null callbackId to the isValidCallbackId. maybe we should test the callbackId first to see if it's null before trying the regex? I'm pretty new to cordova, so please pardon my ignorance if callbackId should never be nil..

      //File: <project>/platforms/ios/CordovaLib/Classes/CDVCommandDelegateImpl.m
      // Function: (BOOL)isValidCallbackId:(NSString *)callbackId

      if (([callbackId length] > 100) || [_callbackIdPattern firstMatchInString:callbackId options:0 range:NSMakeRange(0, [callbackId length])]) {
      return NO;
      }

      /// ERROR THROW:

          • Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]: nil argument'
          • First throw call stack:
            (0x189e6af50 0x1963741fc 0x189e6ae90 0x18a965060 0x18a964f44 0x1000ad758 0x1000ad8b8 0x1000b8c78 0x1000b8028 0x1000b6e74 0x189e6f700 0x189d88eec 0x189d8d744 0x1000bfbac 0x189e6d740 0x189d8d5dc 0x18d198cd0 0x18d199c3c 0x18e2a18f0 0x189e2ae90 0x189e2adf0 0x189e29014 0x189d69c20 0x18fa51c0c 0x18ce9afdc 0x1000b2efc 0x196967aa0)

      // MORE details.
      // The caller of the function that passes the null callbackId iseems to come from the PushPlugin:
      (void)successWithMessage:(NSString *)message
      {
      CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];

      [self.commandDelegate sendPluginResult:commandResult callbackId:self.callbackId];
      }

      Attachments

        Activity

          People

            shazron Shazron Abdullah
            amit777 Amit Gupta
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: