Fix potential XSS vulnerability in break_long_headers template filter (#9435)

The header input is now properly escaped before splitting and joining with <br> tags. This prevents potential XSS attacks if the header contains unsanitized user input.
This commit is contained in:
Seokchan Yoon 2024-06-14 18:52:02 +09:00 committed by GitHub
parent fe92f0dd0d
commit 3b41f01241
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -322,5 +322,5 @@ def break_long_headers(header):
when possible (are comma separated)
"""
if len(header) > 160 and ',' in header:
header = mark_safe('<br> ' + ', <br>'.join(header.split(',')))
header = mark_safe('<br> ' + ', <br>'.join(escape(header).split(',')))
return header