# HG changeset patch # User Emmanuel Gil Peyrot # Date 1305818857 -7200 # Node ID 9b2f17ea1594d057653e68ce79914a146c1a9966 # Parent 8acaa0a575c76eb7362859eeecc52700721862de Add an option to guess the type of an avatar even if it is unspecified. diff --git a/avatar.js b/avatar.js --- a/avatar.js +++ b/avatar.js @@ -146,8 +146,12 @@ function onIq(stanza) { try { var type = photo.getChild('TYPE', 'vcard-temp').getText(); } catch (e) { - svgError(res, 'Error: this user’s vCard doesn’t specify the MIME type of its avatar.'); - return; + if (config.guessType) + type = 'image/png'; // FIXME: use magic. + else { + svgError(res, 'Error: this user’s vCard doesn’t specify the MIME type of its avatar.'); + return; + } } var ext; @@ -155,8 +159,9 @@ function onIq(stanza) { if (type == extensions[i]) ext = i; + // Here we don’t try to guess the extension even if the option is set. if (ext === undefined) { - console.log('Type MIME inconnu : '+type); + console.log('Unknown MIME type: '+type); svgError(res, 'Error: this user’s avatar is in an unknown format.'); return; } diff --git a/configuration.js b/configuration.js --- a/configuration.js +++ b/configuration.js @@ -25,3 +25,4 @@ config.host = 'localhost'; config.port = 5347; config.password = 'hellohello'; config.directory = 'data'; // Directory of the cache. +config.guessType = false; // When true, assume that the TYPE of the avatar is image/png if not specified.