File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -260,7 +260,7 @@ def parse_html_declaration(self, i):
260
260
if rawdata [i :i + 4 ] == '<!--' :
261
261
# this case is actually already handled in goahead()
262
262
return self .parse_comment (i )
263
- elif rawdata [i :i + 3 ] == '<![CDATA[' :
263
+ elif rawdata [i :i + 9 ] == '<![CDATA[' :
264
264
return self .parse_marked_section (i )
265
265
elif rawdata [i :i + 9 ].lower () == '<!doctype' :
266
266
# find the closing >
Original file line number Diff line number Diff line change @@ -635,6 +635,30 @@ def test_broken_condcoms(self):
635
635
]
636
636
self ._run_check (html , expected )
637
637
638
+ def test_cdata_declarations (self ):
639
+ # More tests should be added. See also "8.2.4.42. Markup
640
+ # declaration open state", "8.2.4.69. CDATA section state",
641
+ # and issue 32876
642
+ html = ('<![CDATA[just some plain text]]>' )
643
+ expected = [('unknown decl' , 'CDATA[just some plain text' )]
644
+ self ._run_check (html , expected )
645
+
646
+ def test_cdata_declarations_multiline (self ):
647
+ html = ('<code><![CDATA['
648
+ ' if (a < b && a > b) {'
649
+ ' printf("[<marquee>How?</marquee>]");'
650
+ ' }'
651
+ ']]></code>' )
652
+ expected = [
653
+ ('starttag' , 'code' , []),
654
+ ('unknown decl' ,
655
+ 'CDATA[ if (a < b && a > b) { '
656
+ 'printf("[<marquee>How?</marquee>]"); }' ),
657
+ ('endtag' , 'code' )
658
+ ]
659
+ self ._run_check (html , expected )
660
+
661
+
638
662
def test_convert_charrefs_dropped_text (self ):
639
663
# #23144: make sure that all the events are triggered when
640
664
# convert_charrefs is True, even if we don't call .close()
You can’t perform that action at this time.
0 commit comments