#NEWLINE# def test_exponential_entity_expansion( self ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import defusedxml #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# defusedxml = None #NEWLINE# #UNINDENT# if ( defusedxml is None ) : #NEWLINE# #INDENT# raise SkipTest ( 'This test case only applies when using defusedxml' ) #NEWLINE# #UNINDENT# document_xml = '\n            <p>\n              <r>\n                <t>&c;</t>\n              </r>\n            </p>\n        ' #NEWLINE# xml_header = '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE xml [\n <!ENTITY a "123">\n <!ENTITY b "&a;&a;">\n <!ENTITY c "&b;&b;">\n]>\n        ' #NEWLINE# document = WordprocessingDocumentFactory ( xml_header = xml_header ) #NEWLINE# document . add ( MainDocumentPart , document_xml ) #NEWLINE# expected_html = '<p>123123123123</p>' #NEWLINE# try : #NEWLINE# #INDENT# self . assert_document_generates_html ( document , expected_html ) #NEWLINE# raise AssertionError ( 'Expected "EntitiesForbidden" exception did not occur' ) #NEWLINE# #UNINDENT# except document . EntitiesForbidden : #NEWLINE# #INDENT# pass