@@ -1400,6 +1400,10 @@ def check_valid(self, elem, expected):
14001400 def test_invalid_comment (self ):
14011401 self .check (ET .Comment ('a--b' ))
14021402 self .check (ET .Comment (' B+, B, or B-' ))
1403+ self .check (ET .Comment ('\x00 ' ))
1404+ self .check (ET .Comment ('\x01 ' ))
1405+ self .check (ET .Comment ('\ud8ff ' ))
1406+ self .check (ET .Comment ('\ufffe ' ))
14031407
14041408 def test_invalid_processing_instruction (self ):
14051409 self .check (ET .PI ('' ))
@@ -1412,6 +1416,7 @@ def test_invalid_processing_instruction(self):
14121416 self .check (ET .PI ('xml' , 'encoding="UTF-8"' ))
14131417 self .check (ET .PI ('foo' , 'a?>b' ))
14141418 self .check (ET .PI ('foo' , '\x00 ' ))
1419+ self .check (ET .PI ('foo' , '\x01 ' ))
14151420 self .check (ET .PI ('foo' , '\ud8ff ' ))
14161421 self .check (ET .PI ('foo' , '\ufffe ' ))
14171422
@@ -1500,10 +1505,12 @@ def test_invalid_comment(self):
15001505 self .check (ET .Comment ('a-->b' ))
15011506 self .check (ET .Comment ('a--!>b' ))
15021507 self .check (ET .Comment ('a\x00 b' ))
1508+ self .check (ET .Comment ('a\ud8ff b' ))
15031509
15041510 def test_invalid_processing_instruction (self ):
15051511 self .check (ET .PI ('a>b' ))
15061512 self .check (ET .PI ('a\x00 b' ))
1513+ self .check (ET .PI ('a\ud8ff b' ))
15071514
15081515 def test_invalid_tag (self ):
15091516 self .check (ET .Element ('' ))
@@ -1516,37 +1523,50 @@ def test_invalid_tag(self):
15161523 self .check (ET .Element ('a/b' ))
15171524 self .check (ET .Element ('a>b' ))
15181525 self .check (ET .Element ('a\x00 b' ))
1526+ self .check (ET .Element ('a\ud8ff b' ))
15191527 self .check (ET .Element (ET .QName ('' )))
15201528 self .check (ET .Element (ET .QName ('0' )))
15211529 self .check (ET .Element (ET .QName ('a/b' )))
15221530
15231531 def test_invalid_attr_name (self ):
15241532 self .check (ET .Element ('tag' , attrib = {'' : 'value' }))
1533+ self .check (ET .Element ('tag' , attrib = {'\x00 ' : 'value' }))
1534+ self .check (ET .Element ('tag' , attrib = {'\ud8ff ' : 'value' }))
15251535 self .check (ET .Element ('tag' , attrib = {'a/b' : 'value' }))
15261536 self .check (ET .Element ('tag' , attrib = {'a=b' : 'value' }))
1537+ self .check (ET .Element ('tag' , attrib = {'a\x00 b' : 'value' }))
1538+ self .check (ET .Element ('tag' , attrib = {'a\ud8ff b' : 'value' }))
15271539 self .check (ET .Element ('tag' , attrib = {ET .QName ('' ): 'value' }))
15281540 self .check (ET .Element ('tag' , attrib = {ET .QName ('a/b' ): 'value' }))
15291541
15301542 def test_invalid_attr_value (self ):
15311543 self .check (ET .Element ('tag' , attrib = {'key' : '\x00 ' }))
1544+ self .check (ET .Element ('tag' , attrib = {'key' : '\ud8ff ' }))
15321545 self .check (ET .Element ('tag' , attrib = {'key' : ET .QName ('\x00 ' )}))
1546+ self .check (ET .Element ('tag' , attrib = {'key' : ET .QName ('\ud8ff ' )}))
15331547 self .check (ET .Element ('tag' , attrib = {'key' : ET .QName ('a"b' )}))
15341548 self .check (ET .Element ('tag' , attrib = {'key' : ET .QName ('a&b' )}))
15351549
15361550 def test_invalid_text (self ):
15371551 elem = ET .Element ('tag' )
15381552 elem .text = '\x00 '
15391553 self .check (elem )
1554+ elem .text = '\ud8ff '
1555+ self .check (elem )
15401556
15411557 def test_invalid_tail (self ):
15421558 elem = ET .Element ('tag' )
15431559 elem .tail = '\x00 '
15441560 self .check (elem )
1561+ elem .tail = '\ud8ff '
1562+ self .check (elem )
15451563
15461564 def test_invalid_text_without_tag (self ):
15471565 elem = ET .Element (None )
15481566 elem .text = '\x00 '
15491567 self .check (elem )
1568+ elem .text = '\ud8ff '
1569+ self .check (elem )
15501570
15511571 def test_invalid_subelements (self ):
15521572 elem = ET .Element ('tag' )
@@ -1558,7 +1578,9 @@ def test_invalid_subelements(self):
15581578
15591579 def test_invalid_namespace_uri (self ):
15601580 self .check (ET .Element ('{\x00 }tag' ))
1581+ self .check (ET .Element ('{\ud8ff }tag' ))
15611582 self .check (ET .Element (ET .QName ('\x00 ' , 'tag' )))
1583+ self .check (ET .Element (ET .QName ('\ud8ff ' , 'tag' )))
15621584
15631585 @support .subTests ('tag' , ("script" , "style" , "xmp" , "iframe" , "noembed" , "noframes" ))
15641586 def test_invalid_cdata_content (self , tag ):
@@ -1571,6 +1593,8 @@ def test_invalid_cdata_content(self, tag):
15711593 self .check (elem )
15721594 elem .text = 'a\x00 b'
15731595 self .check (elem )
1596+ elem .text = 'a\ud8ff b'
1597+ self .check (elem )
15741598
15751599 @support .subTests ('tag' , ("script" , "style" , "xmp" , "iframe" , "noembed" , "noframes" ))
15761600 def test_cdata_subelements (self , tag ):
@@ -1582,6 +1606,8 @@ def test_invalid_plaintext_content(self):
15821606 elem = ET .Element ('plaintext' )
15831607 elem .text = 'a\x00 b'
15841608 self .check (elem )
1609+ elem .text = 'a\ud8ff b'
1610+ self .check (elem )
15851611
15861612
15871613class IterparseTest (unittest .TestCase ):
0 commit comments