Skip to content

Commit 3b41f01

Browse files
authored
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.
1 parent fe92f0d commit 3b41f01

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rest_framework/templatetags/rest_framework.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,5 +322,5 @@ def break_long_headers(header):
322322
when possible (are comma separated)
323323
"""
324324
if len(header) > 160 and ',' in header:
325-
header = mark_safe('<br> ' + ', <br>'.join(header.split(',')))
325+
header = mark_safe('<br> ' + ', <br>'.join(escape(header).split(',')))
326326
return header

0 commit comments

Comments
 (0)