apache: HTML Escape the method when showing error message

Tests:

- Visit the URL /freedombox/apache/discover-idp/?method=<i>blah</i>. The shown
HTML error message escapes the HTML properly with the patch and doesn't without.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2026-11-28 08:31:42 -05:00
1 parent 9224786e57
commit 93979feafd
1 file changed
+3 -1
+3 -1
View File
@@ -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()