Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off parsing external entities #14

Merged
merged 2 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Turn off resolve_entities while parsing xml
  • Loading branch information
dputtick committed Jul 27, 2017
commit 026a5d5271d618c21cd3c1594de34ff37a511207
3 changes: 2 additions & 1 deletion officedissector/part.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ def xml(self):

:return: an `ElementTree` of the parsed XML
"""
parser = etree.XMLParser(resolve_entities=False)
try:
xml_etree = etree.parse(self.stream())
xml_etree = etree.parse(self.stream(), parser)
except etree.XMLSyntaxError:
print('part cannot be parsed successfully: %r' % self)
raise
Expand Down
3 changes: 3 additions & 0 deletions test/unit_test/test_officedissector.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ def testAssertions(self):
self.assertEqual(self.test_stdout.getvalue(),
'part cannot be parsed successfully: Part [/[Content_Types].xml]')

def testDenialOfService(self):
doc = Document('testdocs/dos.docx')


def main():
os.chdir(os.path.abspath(os.path.dirname(__file__)))
Expand Down