mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-01 13:06:45 +00:00
parent
cb0f0e34d9
commit
18d9ecd0f4
@ -43,7 +43,7 @@ ALLOWED_ATTRIBUTES_SVG = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def sanitize_svg(file_data: str, strip: bool = True, elements: str = ALLOWED_ELEMENTS_SVG, attributes: str = ALLOWED_ATTRIBUTES_SVG) -> str:
|
def sanitize_svg(file_data, strip: bool = True, elements: str = ALLOWED_ELEMENTS_SVG, attributes: str = ALLOWED_ATTRIBUTES_SVG) -> str:
|
||||||
"""Sanatize a SVG file.
|
"""Sanatize a SVG file.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -56,6 +56,10 @@ def sanitize_svg(file_data: str, strip: bool = True, elements: str = ALLOWED_ELE
|
|||||||
str: Sanitzied SVG file.
|
str: Sanitzied SVG file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Handle byte-encoded data
|
||||||
|
if type(file_data) == bytes:
|
||||||
|
file_data = file_data.decode('utf-8')
|
||||||
|
|
||||||
cleaned = clean(
|
cleaned = clean(
|
||||||
file_data,
|
file_data,
|
||||||
tags=elements,
|
tags=elements,
|
||||||
@ -64,4 +68,5 @@ def sanitize_svg(file_data: str, strip: bool = True, elements: str = ALLOWED_ELE
|
|||||||
strip_comments=strip,
|
strip_comments=strip,
|
||||||
css_sanitizer=CSSSanitizer()
|
css_sanitizer=CSSSanitizer()
|
||||||
)
|
)
|
||||||
|
|
||||||
return cleaned
|
return cleaned
|
||||||
|
Loading…
x
Reference in New Issue
Block a user