Unable to bind any 'keypress' event where object isPlainObject as hotkeys handler tries to reference undefined object

XMLWordPrintable

    • 5.02
    • Severity 2 - Major

      Summary:
      code in JIRA 5.2's jquery.hotkeys.js is not fully handling the case where the event object passed isPlainObject. It tries dereferencing <event>.combo which is never set in this particular case. The versions of this code in JIRA 5.0 and 5.1 work properly.

      Details:
      In a plugin we're developing, we're including a library that calls jQuery.bind to bind an event handler to "keypress".

      JIRA's hotkeys JS code has registered an event "add" handler (see jquery.hotkeys.js – at least in 5.1 source) for "keypress" which gets called to add handling for the custom keypress event registered by the 3rd party library.

      The problem is, for the event we're trying to add isPlainObject = true. This particular case never sets the .combo property on the event before jQuery.map is called passing the .combo property as a key. Since .combo is undefined, jQuery.map fails with an unhandled JS exception – specifically within the .map function the attempt to get .length on the first parameter passed (undefined) generates the exception.

      Here's the stack trace from JS where things blow up...

      e.extend.map (batch.js:525)
      (anonymous function) (batch.js:8611)
      C (batch.js:8614)
      f.event.add (batch.js:1115)
      (anonymous function) (batch.js:1301)
      e.extend.each (batch.js:483)
      e.fn.e.each (batch.js:348)
      f.fn.extend.on (batch.js:1300)
      f.fn.extend.bind (batch.js:1323)
      _fnBindAction (jquery.dataTables.js:2514)
      $.extend.full_numbers.fnInit (jquery.dataTables.js:3519)
      _fnFeatureHtmlPaginate (jquery.dataTables.js:1505)
      _fnAddOptionsHtml (jquery.dataTables.js:914)
      _fnInitialise (jquery.dataTables.js:1364)
      (anonymous function) (jquery.dataTables.js:3354)
      e.extend.each (batch.js:483)
      e.fn.e.each (batch.js:348)
      DataTable (jquery.dataTables.js:3096)
      Arsenale.Dataplane.ReportConfig.decorateTableDataViews (reportConfig.js:41)
      (anonymous function) (reportConfig.js:151)
      n (batch.js:593)
      o.fireWith (batch.js:638)
      w (batch.js:2498)
      d (batch.js:2667)

      where the exception is happening in JIRA's jquery.hotkeys.js...

      function C(G) {
      if (!(D.isPlainObject(G.data) || D.isArray(G.data) || typeof G.data === "string"))

      { return }

      var F = G.handler, E =

      {timer: 700}

      ;
      (function(H) {
      if (typeof H === "string")

      { E.combo = [H] }

      else {
      if (D.isArray(H))

      { E.combo = H }

      else

      { D.extend(E, H) }

      }
      E.combo = D.map(E.combo, function(I)

      { <============= E.combo undefined when D.isPlainObject return I.toLowerCase() }

      )
      })(G.data);

            Assignee:
            Unassigned
            Reporter:
            David Goldstein [Arsenale]
            Votes:
            5 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: