File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
netbox/utilities/templatetags Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 1717* [ #7766 ] ( https://github.com/netbox-community/netbox/issues/7766 ) - Add missing outer dimension columns to rack table
1818* [ #7780 ] ( https://github.com/netbox-community/netbox/issues/7780 ) - Preserve multi-line values during CSV file import
1919* [ #7783 ] ( https://github.com/netbox-community/netbox/issues/7783 ) - Fix indentation of locations under site view
20+ * [ #7788 ] ( https://github.com/netbox-community/netbox/issues/7788 ) - Improve XSS mitigation in Markdown renderer
2021* [ #7791 ] ( https://github.com/netbox-community/netbox/issues/7791 ) - Enable sorting device bays table by installed device status
2122* [ #7802 ] ( https://github.com/netbox-community/netbox/issues/7802 ) - Differentiate ID and VID columns in VLANs table
2223
Original file line number Diff line number Diff line change @@ -40,14 +40,19 @@ def render_markdown(value):
4040 """
4141 Render text as Markdown
4242 """
43+ schemes = '|' .join (settings .ALLOWED_URL_SCHEMES )
44+
4345 # Strip HTML tags
4446 value = strip_tags (value )
4547
4648 # Sanitize Markdown links
47- schemes = '|' .join (settings .ALLOWED_URL_SCHEMES )
48- pattern = fr'\[(.+)\]\((?!({ schemes } )).*:(.+)\)'
49+ pattern = fr'\[([^\]]+)\]\((?!({ schemes } )).*:(.+)\)'
4950 value = re .sub (pattern , '[\\ 1](\\ 3)' , value , flags = re .IGNORECASE )
5051
52+ # Sanitize Markdown reference links
53+ pattern = fr'\[(.+)\]:\w?(?!({ schemes } )).*:(.+)'
54+ value = re .sub (pattern , '[\\ 1]: \\ 3' , value , flags = re .IGNORECASE )
55+
5156 # Render Markdown
5257 html = markdown (value , extensions = ['fenced_code' , 'tables' ])
5358
You can’t perform that action at this time.
0 commit comments