From fd75e91e7544939faf302caef453a81cef48f420 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 14 May 2022 18:16:13 -0400 Subject: [PATCH] Ignore DOMExceptions thrown by assigning an invalid dataset property (#2133) --- ext/js/display/sandbox/structured-content-generator.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/js/display/sandbox/structured-content-generator.js b/ext/js/display/sandbox/structured-content-generator.js index 5b11965a..0e287dc2 100644 --- a/ext/js/display/sandbox/structured-content-generator.js +++ b/ext/js/display/sandbox/structured-content-generator.js @@ -166,7 +166,11 @@ class StructuredContentGenerator { key = `${key[0].toUpperCase()}${key.substring(1)}`; } key = `sc${key}`; - element.dataset[key] = value; + try { + element.dataset[key] = value; + } catch (e) { + // DOMException if key is malformed + } } }