Skip to content

Commit

Permalink
Assert that existingMapping is an array.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kesselberg <[email protected]>
  • Loading branch information
kesselb committed Feb 26, 2020
1 parent 6742d2f commit 3a5ca0c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion keeweb/lib/Migration/RegisterMimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion keeweb/lib/Migration/UnregisterMimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down

0 comments on commit 3a5ca0c

Please sign in to comment.