From 79b19a17a3160e461a62aadfa557f57b36e1e05d Mon Sep 17 00:00:00 2001 From: Aristotelis <5459332+glutanimate@users.noreply.github.com> Date: Thu, 24 Apr 2025 07:28:25 +0200 Subject: [PATCH] Add add-on scripts to editor CSP (#3942) --- qt/aqt/mediasrv.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qt/aqt/mediasrv.py b/qt/aqt/mediasrv.py index f160b84a9..bdf9cdc0f 100644 --- a/qt/aqt/mediasrv.py +++ b/qt/aqt/mediasrv.py @@ -752,8 +752,12 @@ def legacy_page_data() -> Response: # have access to our internal API, and is a security risk. if page.context == PageContext.EDITOR: port = aqt.mw.mediaServer.getPort() + csp_paths = ( + f"http://127.0.0.1:{port}/_anki/", + f"http://127.0.0.1:{port}/_addons/", + ) response.headers["Content-Security-Policy"] = ( - f"script-src http://127.0.0.1:{port}/_anki/" + f"script-src {' '.join(csp_paths)}" ) return response else: