From f1c21ff23b3353fe857953f23cd86aa83f59cf9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Thu, 19 Jun 2014 12:48:12 +0100 Subject: [PATCH] Catch broken UTF-8 to enable loading of buffers with broken lines --- js/weechat.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/weechat.js b/js/weechat.js index 0b220b1..bd9870b 100644 --- a/js/weechat.js +++ b/js/weechat.js @@ -574,10 +574,13 @@ WeeChatProtocol._uia2s = function(uia) { if(!uia.length || uia[0] === 0) return ""; - var encodedString = String.fromCharCode.apply(null, uia), - decodedString = decodeURIComponent(escape(encodedString)); - - return decodedString; + try { + var encodedString = String.fromCharCode.apply(null, uia), + decodedString = decodeURIComponent(escape(encodedString)); + return decodedString; + } catch (exception) { + return "--Sorry, Glowing Bear cannot decode this line as it is invalid--"; + } }; /**