From 1ced9aafc00c10992bab8bd3f1b6b1397f05b7b9 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 19 Dec 2023 00:33:38 -0500 Subject: Make JSON.parse usage safer (#373) * Make JSON.parse usage safer * Fix any type * Add readResponseJson * Use readResponseJson * Additional updates * Rename files * Add types --- ext/js/input/hotkey-help-controller.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ext/js/input/hotkey-help-controller.js') diff --git a/ext/js/input/hotkey-help-controller.js b/ext/js/input/hotkey-help-controller.js index 4a3c0264..14063d9a 100644 --- a/ext/js/input/hotkey-help-controller.js +++ b/ext/js/input/hotkey-help-controller.js @@ -17,6 +17,7 @@ */ import {isObject} from '../core.js'; +import {parseJson} from '../core/json.js'; import {yomitan} from '../yomitan.js'; import {HotkeyUtil} from './hotkey-util.js'; @@ -149,7 +150,7 @@ export class HotkeyHelpController { _getNodeInfo(node) { const {hotkey} = node.dataset; if (typeof hotkey !== 'string') { return null; } - const data = /** @type {unknown} */ (JSON.parse(hotkey)); + const data = /** @type {unknown} */ (parseJson(hotkey)); if (!Array.isArray(data)) { return null; } const [action, attributes, values] = data; if (typeof action !== 'string') { return null; } -- cgit v1.2.3