From 811c9f5f92604f2728cb74ff0622dd173a701976 Mon Sep 17 00:00:00 2001 From: Dominik Hebeler <dominik@suma-ev.de> Date: Mon, 8 Jul 2024 14:44:56 +0200 Subject: [PATCH] handle undefined keys --- pass/app/Key.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pass/app/Key.js b/pass/app/Key.js index 3e1f2b8..1f513c6 100644 --- a/pass/app/Key.js +++ b/pass/app/Key.js @@ -304,6 +304,10 @@ class Key { static async GET_KEY(key, writable = false) { // Check if supplied key is UUID v4 if (!Key.IS_VALID_UUID(key)) { + if (typeof key != "string") { + key = ""; + } + const { createHash } = await import("node:crypto"); let hash = createHash("md5"); hash.update(key); @@ -391,8 +395,8 @@ class Key { }); } - static IS_VALID_UUID(input_key){ - if(!input_key || typeof input_key != "string") return false; + static IS_VALID_UUID(input_key) { + if (!input_key || typeof input_key != "string") return false; return input_key.match( /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i ); -- GitLab