From b59e843f5815de869c5fab021641dd8608dbb390 Mon Sep 17 00:00:00 2001 From: Christoph Burschka Date: Tue, 29 Dec 2015 17:27:08 +0100 Subject: [PATCH] Fix #313: Drop messages without a body element. Message stanzas may convey only meta-data and not be intended for direct display (such as XEP-0085 chat status notifications). Cadence shouldn't render these as blank messages. --- js/core/xmpp.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/core/xmpp.js b/js/core/xmpp.js index e2d8df9..9bf5edc 100644 --- a/js/core/xmpp.js +++ b/js/core/xmpp.js @@ -917,8 +917,11 @@ var xmpp = { if (type == 'error') return this.eventMessageError(stanza, node, domain, resource) || true; + // If there is no element, drop the message. (@TODO #201 XEP-0085) + if (!$(stanza).children('body').length) return true; + var body = $('html body p', stanza).contents(); - if (!body.length) body = $('body:first', stanza).contents(); + if (!body.length) body = $(stanza).children('body').contents(); var delay = $('delay', stanza); var time = delay.attr('stamp') || (new Date()).toISOString();