Skip to content

Commit

Permalink
set XMLParser(resolve_entities=False), it's safer and we don't need t…
Browse files Browse the repository at this point in the history
…o resolve external entities anyway
  • Loading branch information
anthrotype committed Sep 15, 2023
1 parent 2c304b5 commit a0bcfad
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/picosvg/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,13 @@ def fromstring(cls, string):
string = string.replace("xlink:href", _XLINK_TEMP)

# encode because fromstring dislikes xml encoding decl if input is str
parser = etree.XMLParser(remove_comments=True, remove_blank_text=True)
parser = etree.XMLParser(
remove_comments=True,
remove_blank_text=True,
# external entities may load local files (e.g. /etc/passwd), so disable
# safe entities like > are still allowed
resolve_entities=False,
)
tree = etree.fromstring(string.encode("utf-8"), parser)
tree = _fix_xlink_ns(tree)
return cls(tree)
Expand Down

0 comments on commit a0bcfad

Please sign in to comment.