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/dom/sandbox/css-style-applier.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ext/js/dom') diff --git a/ext/js/dom/sandbox/css-style-applier.js b/ext/js/dom/sandbox/css-style-applier.js index 200fd05f..6925f263 100644 --- a/ext/js/dom/sandbox/css-style-applier.js +++ b/ext/js/dom/sandbox/css-style-applier.js @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +import {readResponseJson} from '../../core/json.js'; + /** * This class is used to apply CSS styles to elements using a consistent method * that is the same across different browsers. @@ -99,8 +101,9 @@ export class CssStyleApplier { /** * Fetches and parses a JSON file. + * @template [T=unknown] * @param {string} url The URL to the file. - * @returns {Promise<*>} A JSON object. + * @returns {Promise} A JSON object. * @throws {Error} An error is thrown if the fetch fails. */ async _fetchJsonAsset(url) { @@ -115,7 +118,7 @@ export class CssStyleApplier { if (!response.ok) { throw new Error(`Failed to fetch ${url}: ${response.status}`); } - return await response.json(); + return await readResponseJson(response); } /** -- cgit v1.2.3