From a121eb4dacbd8f8a7aea9cdf14d9775f09f1678c Mon Sep 17 00:00:00 2001 From: Gopavasanth Date: Sun, 22 Feb 2026 22:02:14 +0530 Subject: [PATCH 1/3] feat: implement Content Security Policy and update dependencies in HTML template --- app.py | 14 ++++++++++++++ templates/home.html | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 0b3beed..791a6cf 100644 --- a/app.py +++ b/app.py @@ -10,6 +10,20 @@ app = Flask(__name__) CORS(app) # Enable CORS for all routes +CSP_POLICY = ( + "default-src 'self'; " + "script-src 'self' 'unsafe-inline' https://tools-static.wmflabs.org; " + "style-src 'self' 'unsafe-inline' https://tools-static.wmflabs.org; " + "connect-src 'self' https://api.github.com; " + "img-src 'self' data:; " + "font-src 'self' https://tools-static.wmflabs.org data:" +) + +@app.after_request +def set_security_headers(response): + response.headers['Content-Security-Policy'] = CSP_POLICY + return response + behaviour_switches = ['__NOTOC__', '__FORCETOC__', '__TOC__', '__NOEDITSECTION__', '__NEWSECTIONLINK__', '__NONEWSECTIONLINK__', '__NOGALLERY__', '__HIDDENCAT__', '__EXPECTUNUSEDCATEGORY__', '__NOCONTENTCONVERT__', '__NOCC__', '__NOTITLECONVERT__', '__NOTC__', '__START__', '__END__', '__INDEX__', '__NOINDEX__', '__STATICREDIRECT__', '__EXPECTUNUSEDTEMPLATE__', '__NOGLOBAL__', '__DISAMBIG__', '__EXPECTED_UNCONNECTED_PAGE__', '__ARCHIVEDTALK__', '__NOTALK__', '__EXPECTWITHOUTSCANS__'] # --- Helper Functions for Processing Different Wikitext Elements --- diff --git a/templates/home.html b/templates/home.html index ab54321..9cf2d70 100644 --- a/templates/home.html +++ b/templates/home.html @@ -6,12 +6,12 @@ Wikitext to Translatable Wikitext Converter