Skip to content
Snippets Groups Projects
Commit 811c9f5f authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

handle undefined keys

parent 050d5f12
No related branches found
No related tags found
No related merge requests found
Pipeline #9936 passed
......@@ -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
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment