summaryrefslogtreecommitdiff
path: root/ext/js/comm/anki-connect.js
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/comm/anki-connect.js
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/comm/anki-connect.js')
-rw-r--r--ext/js/comm/anki-connect.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/js/comm/anki-connect.js b/ext/js/comm/anki-connect.js
index bd9a69a2..fa5543d5 100644
--- a/ext/js/comm/anki-connect.js
+++ b/ext/js/comm/anki-connect.js
@@ -17,6 +17,7 @@
*/
import {ExtensionError} from '../core/extension-error.js';
+import {parseJson} from '../core/json.js';
import {AnkiUtil} from '../data/anki-util.js';
/**
@@ -419,7 +420,7 @@ export class AnkiConnect {
let result;
try {
responseText = await response.text();
- result = JSON.parse(responseText);
+ result = parseJson(responseText);
} catch (e) {
const error = new ExtensionError('Invalid Anki response');
error.data = {action, params, status: response.status, responseText, originalError: e};