From 3117a15790cc13ff7148326ad59f88aaee6c1ec1 Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Mon, 26 Mar 2018 10:37:39 +0200 Subject: [PATCH] Fixed javascript error when the mime_type of an item is not a string --- build/libifm.php | 10 ++++++---- ifm.php | 10 ++++++---- src/ifm.js | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/build/libifm.php b/build/libifm.php index b4208d8..da6cb9b 100644 --- a/build/libifm.php +++ b/build/libifm.php @@ -1572,10 +1572,12 @@ function IFM( params ) { } else if( self.config.edit && ( - item.mime_type.substr( 0, 4 ) == "text" - || item.mime_type == "inode/x-empty" - || item.mime_type.indexOf( "xml" ) != -1 - || item.mime_type.indexOf( "json" ) != -1 + typeof item.mime_type === "string" && ( + item.mime_type.substr( 0, 4 ) == "text" + || item.mime_type == "inode/x-empty" + || item.mime_type.indexOf( "xml" ) != -1 + || item.mime_type.indexOf( "json" ) != -1 + ) ) ) { item.eaction = "edit"; diff --git a/ifm.php b/ifm.php index 1199f8d..0cb7518 100644 --- a/ifm.php +++ b/ifm.php @@ -1572,10 +1572,12 @@ function IFM( params ) { } else if( self.config.edit && ( - item.mime_type.substr( 0, 4 ) == "text" - || item.mime_type == "inode/x-empty" - || item.mime_type.indexOf( "xml" ) != -1 - || item.mime_type.indexOf( "json" ) != -1 + typeof item.mime_type === "string" && ( + item.mime_type.substr( 0, 4 ) == "text" + || item.mime_type == "inode/x-empty" + || item.mime_type.indexOf( "xml" ) != -1 + || item.mime_type.indexOf( "json" ) != -1 + ) ) ) { item.eaction = "edit"; diff --git a/src/ifm.js b/src/ifm.js index 0017491..b360c74 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -148,10 +148,12 @@ function IFM( params ) { } else if( self.config.edit && ( - item.mime_type.substr( 0, 4 ) == "text" - || item.mime_type == "inode/x-empty" - || item.mime_type.indexOf( "xml" ) != -1 - || item.mime_type.indexOf( "json" ) != -1 + typeof item.mime_type === "string" && ( + item.mime_type.substr( 0, 4 ) == "text" + || item.mime_type == "inode/x-empty" + || item.mime_type.indexOf( "xml" ) != -1 + || item.mime_type.indexOf( "json" ) != -1 + ) ) ) { item.eaction = "edit";