From 93979feafded17a75f07296b49b4fd0f12cff0cf Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 23 Nov 2026 15:04:43 -0800 Subject: [PATCH] apache: HTML Escape the method when showing error message Tests: - Visit the URL /freedombox/apache/discover-idp/?method=blah. The shown HTML error message escapes the HTML properly with the patch and doesn't without. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- freedombox/modules/apache/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/freedombox/modules/apache/views.py b/freedombox/modules/apache/views.py index bc46f9b1b..21b52f85f 100644 --- a/freedombox/modules/apache/views.py +++ b/freedombox/modules/apache/views.py @@ -5,6 +5,7 @@ from urllib.parse import urlencode, urlparse from django.http import (HttpResponseBadRequest, HttpResponseRedirect, HttpResponseServerError) +from django.utils.html import escape from django.views import View from . import setup_oidc_client, validate_host @@ -36,7 +37,8 @@ class DiscoverIDPView(View): oidc_callback = request.GET.get('oidc_callback') if method != 'get': - return HttpResponseBadRequest(f'Cannot handle "{method}" method') + return HttpResponseBadRequest( + f'Cannot handle "{escape(method)}" method') oidc_callback_parts = urlparse(oidc_callback) request_host = request.get_host()