Skip to content

Commit

Permalink
Fix potential XSS vulnerability in break_long_headers template filter (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
ch4n3-yoon committed Jun 14, 2024
1 parent fe92f0d commit 3b41f01
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rest_framework/templatetags/rest_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3b41f01

Please sign in to comment.