aboutsummaryrefslogtreecommitdiff
path: root/ext/js/media
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-19 00:33:38 -0500
committerGitHub <noreply@github.com>2023-12-19 05:33:38 +0000
commit1ced9aafc00c10992bab8bd3f1b6b1397f05b7b9 (patch)
tree305bb2b3bfc7fc3b051ee1cd3d1c35f442af0de4 /ext/js/media
parent5f96276fda93dcad39f2165fd3c8d890aa5f9be5 (diff)
Make JSON.parse usage safer (#373)
* Make JSON.parse usage safer * Fix any type * Add readResponseJson * Use readResponseJson * Additional updates * Rename files * Add types
Diffstat (limited to 'ext/js/media')
-rw-r--r--ext/js/media/audio-downloader.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/js/media/audio-downloader.js b/ext/js/media/audio-downloader.js
index e041cc67..a9b2133b 100644
--- a/ext/js/media/audio-downloader.js
+++ b/ext/js/media/audio-downloader.js
@@ -18,6 +18,7 @@
import {RequestBuilder} from '../background/request-builder.js';
import {ExtensionError} from '../core/extension-error.js';
+import {readResponseJson} from '../core/json.js';
import {JsonSchema} from '../data/json-schema.js';
import {ArrayBufferUtil} from '../data/sandbox/array-buffer-util.js';
import {NativeSimpleDOMParser} from '../dom/native-simple-dom-parser.js';
@@ -272,7 +273,8 @@ export class AudioDownloader {
throw new Error(`Invalid response: ${response.status}`);
}
- const responseJson = await response.json();
+ /** @type {import('audio-downloader').CustomAudioList} */
+ const responseJson = await readResponseJson(response);
if (this._customAudioListSchema === null) {
const schema = await this._getCustomAudioListSchema();
@@ -425,6 +427,6 @@ export class AudioDownloader {
redirect: 'follow',
referrerPolicy: 'no-referrer'
});
- return await response.json();
+ return await readResponseJson(response);
}
}