Improve handling of invalid URIs in attachements

Change-Id: I6fbbb43c6e250c7041e59a55d6e62d3cbdc531b6
diff --git a/dev/js/src/match/attachement.js b/dev/js/src/match/attachement.js
index 70a2a20..45c4b21 100644
--- a/dev/js/src/match/attachement.js
+++ b/dev/js/src/match/attachement.js
@@ -29,8 +29,18 @@
     _init : function (url) {
       const t = this;
 
+      t.base64 = false;
+      t.isLink = false;
+      t.contentType = "text/plain";
+      
       // Decode
-      url = decodeURIComponent(url);
+      var url;
+      try {
+        url = decodeURIComponent(url);
+      } catch (e) {
+        t.payload = '[INVALID URI]';
+        return t;
+      }
 
       if (!uriRE.exec(url))
         return;
@@ -39,9 +49,6 @@
 
       let map = {};
       let start = 0;
-      t.base64 = false;
-      t.isLink = false;
-      t.contentType = "text/plain";
 
       // Split parameter map
       RegExp.$1.split(/ *; */).map(function (item) {