 from __future__ import ( <EOL> absolute_import , <EOL> print_function , <EOL> unicode_literals , <EOL> ) <EOL> from nose import SkipTest <EOL> from pydocx . test import DocumentGeneratorTestCase <EOL> from pydocx . test . utils import WordprocessingDocumentFactory <EOL> from pydocx . openxml . packaging import MainDocumentPart <EOL> class XMLVulnerabilitiesTestCase ( DocumentGeneratorTestCase ) : <EOL> def test_exponential_entity_expansion ( self ) : <EOL> try : <EOL> import defusedxml <EOL> except ImportError : <EOL> defusedxml = None <EOL> if defusedxml is None : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> document_xml = '''<STR_LIT>''' <EOL> xml_header = '''<STR_LIT>''' <EOL> document = WordprocessingDocumentFactory ( xml_header = xml_header ) <EOL> document . add ( MainDocumentPart , document_xml ) <EOL> expected_html = '<STR_LIT>' <EOL> try : 
 self . assert_document_generates_html ( document , expected_html ) 
 from __future__ import ( <EOL> absolute_import , <EOL> print_function , <EOL> unicode_literals , <EOL> ) <EOL> from nose import SkipTest <EOL> from pydocx . test import DocumentGeneratorTestCase <EOL> from pydocx . test . utils import WordprocessingDocumentFactory <EOL> from pydocx . openxml . packaging import MainDocumentPart <EOL> class XMLVulnerabilitiesTestCase ( DocumentGeneratorTestCase ) : <EOL> def test_exponential_entity_expansion ( self ) : <EOL> try : <EOL> import defusedxml <EOL> except ImportError : <EOL> defusedxml = None <EOL> if defusedxml is None : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> document_xml = '''<STR_LIT>''' <EOL> xml_header = '''<STR_LIT>''' <EOL> document = WordprocessingDocumentFactory ( xml_header = xml_header ) <EOL> document . add ( MainDocumentPart , document_xml ) <EOL> expected_html = '<STR_LIT>' <EOL> try : <EOL> self . assert_document_generates_html ( document , expected_html ) <EOL> raise AssertionError ( <EOL> '<STR_LIT>' , <EOL> ) <EOL> except defusedxml . EntitiesForbidden : <EOL> pass <EOL> def test_entity_blowup ( self ) : <EOL> try : <EOL> import defusedxml <EOL> except ImportError : <EOL> defusedxml = None <EOL> if defusedxml is None : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> document_xml = '''<STR_LIT>''' <EOL> xml_header = '''<STR_LIT>''' <EOL> document = WordprocessingDocumentFactory ( xml_header = xml_header ) <EOL> document . add ( MainDocumentPart , document_xml ) <EOL> expected_html = '<STR_LIT>' <EOL> try : <EOL> self . assert_document_generates_html ( document , expected_html ) <EOL> raise AssertionError ( <EOL> '<STR_LIT>' , <EOL> ) <EOL> except defusedxml . EntitiesForbidden : <EOL> pass </s>
