[sushi] mimeHandler: check for mimeTypes when populating list of viewers



commit 7610960f557e8fbb3a40c8f0f6b60f465c67ff84
Author: Joel Ong <joel hyad es>
Date:   Wed Apr 13 17:18:37 2022 -0400

    mimeHandler: check for mimeTypes when populating list of viewers
    
    In particular, we now do not add viewer to list of renderers if no
    `mimeTypes` property is present. This fixes #80 and also protects
    against malformed custom viewers in the user home directory.

 src/ui/mimeHandler.js | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/ui/mimeHandler.js b/src/ui/mimeHandler.js
index 1d17e41..d704b25 100644
--- a/src/ui/mimeHandler.js
+++ b/src/ui/mimeHandler.js
@@ -33,8 +33,11 @@ var renderers = [];
 let localPath = GLib.build_filenamev([GLib.get_user_data_dir(), 'sushi']);
 imports.searchPath.push(localPath);
 
-for (let i in imports.viewers)
-    renderers.push(imports.viewers[i]);
+for (let i in imports.viewers) {
+    if (imports.viewers[i].hasOwnProperty('mimeTypes')) {
+        renderers.push(imports.viewers[i]);
+    }
+}
 
 var getKlass = function(mime) {
     let renderer = renderers.find((r) => {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]