# HG changeset patch # User Emmanuel Gil Peyrot # Date 1301524519 -7200 # Node ID 0c19fadfc12d054fe56cd54c1d20f7913318e27e # Parent d5cfe54f11aab3fd32b7ca1a2e1c831165c1cf84 Serve the right error message when the TYPE of the PHOTO is missing. diff --git a/avatar.js b/avatar.js --- a/avatar.js +++ b/avatar.js @@ -139,9 +139,15 @@ function onIq(stanza) { try { var photo = vCard.getChild('PHOTO', 'vcard-temp'); - var type = photo.getChild('TYPE', 'vcard-temp').getText(); var base64 = photo.getChild('BINVAL', 'vcard-temp').getText(); + try { + var type = photo.getChild('TYPE', 'vcard-temp').getText(); + } catch (e) { + res.writeHead(500, {'Content-Type': 'text/plain'}); + res.end('Error: this user’s vCard doesn’t specify the MIME type of its avatar.'); + } + var ext; for (var i in extensions) if (type == extensions[i])