From 3a5ca0c50e27ebf449507a02544d61ec050225ab Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Wed, 26 Feb 2020 23:35:15 +0100 Subject: [PATCH] Assert that existingMapping is an array. Signed-off-by: Daniel Kesselberg --- keeweb/lib/Migration/RegisterMimeType.php | 2 +- keeweb/lib/Migration/UnregisterMimeType.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/keeweb/lib/Migration/RegisterMimeType.php b/keeweb/lib/Migration/RegisterMimeType.php index b0f739c..89a00bc 100644 --- a/keeweb/lib/Migration/RegisterMimeType.php +++ b/keeweb/lib/Migration/RegisterMimeType.php @@ -26,7 +26,7 @@ private function registerForNewFiles() if (file_exists($mappingFile)) { $existingMapping = json_decode(file_get_contents($mappingFile), true); - if (json_last_error() === JSON_ERROR_NONE) { + if (json_last_error() === JSON_ERROR_NONE && is_array($existingMapping)) { $mapping = array_merge($existingMapping, $mapping); } } diff --git a/keeweb/lib/Migration/UnregisterMimeType.php b/keeweb/lib/Migration/UnregisterMimeType.php index bfd7ea1..8efe2fd 100644 --- a/keeweb/lib/Migration/UnregisterMimeType.php +++ b/keeweb/lib/Migration/UnregisterMimeType.php @@ -25,7 +25,7 @@ private function unregisterForNewFiles() if (file_exists($mappingFile)) { $mapping = json_decode(file_get_contents($mappingFile), true); - if (json_last_error() === JSON_ERROR_NONE) { + if (json_last_error() === JSON_ERROR_NONE && is_array($mapping)) { unset($mapping['kdbx']); } else { $mapping = [];