Fix potential XSS vulnerability in break_long_headers template filter

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:
ch4n3-yoon 2024-06-13 20:09:09 +09:00
parent fe92f0dd0d
commit bc1c41d374

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