@@ -317,6 +317,49 @@ def test_style_content(self, content):
317
317
("data" , content ),
318
318
("endtag" , "style" )])
319
319
320
+ @support .subTests ('content' , [
321
+ '<!-- not a comment -->' ,
322
+ "<not a='start tag'>" ,
323
+ '<![CDATA[not a cdata]]>' ,
324
+ '<!not a bogus comment>' ,
325
+ '</not a bogus comment>' ,
326
+ '\u2603 ' ,
327
+ '< /title>' ,
328
+ '</ title>' ,
329
+ '</titled>' ,
330
+ '</title\v >' ,
331
+ '</title\xa0 >' ,
332
+ '</tıtle>' ,
333
+ ])
334
+ def test_title_content (self , content ):
335
+ source = f"<title>{ content } </title>"
336
+ self ._run_check (source , [
337
+ ("starttag" , "title" , []),
338
+ ("data" , content ),
339
+ ("endtag" , "title" ),
340
+ ])
341
+
342
+ @support .subTests ('content' , [
343
+ '<!-- not a comment -->' ,
344
+ "<not a='start tag'>" ,
345
+ '<![CDATA[not a cdata]]>' ,
346
+ '<!not a bogus comment>' ,
347
+ '</not a bogus comment>' ,
348
+ '\u2603 ' ,
349
+ '< /textarea>' ,
350
+ '</ textarea>' ,
351
+ '</textareable>' ,
352
+ '</textarea\v >' ,
353
+ '</textarea\xa0 >' ,
354
+ ])
355
+ def test_textarea_content (self , content ):
356
+ source = f"<textarea>{ content } </textarea>"
357
+ self ._run_check (source , [
358
+ ("starttag" , "textarea" , []),
359
+ ("data" , content ),
360
+ ("endtag" , "textarea" ),
361
+ ])
362
+
320
363
@support .subTests ('endtag' , ['script' , 'SCRIPT' , 'script ' , 'script\n ' ,
321
364
'script/' , 'script foo=bar' , 'script foo=">"' ])
322
365
def test_script_closing_tag (self , endtag ):
@@ -346,6 +389,38 @@ def test_style_closing_tag(self, endtag):
346
389
("endtag" , "style" )],
347
390
collector = EventCollectorNoNormalize (convert_charrefs = False ))
348
391
392
+ @support .subTests ('endtag' , ['title' , 'TITLE' , 'title ' , 'title\n ' ,
393
+ 'title/' , 'title foo=bar' , 'title foo=">"' ])
394
+ def test_title_closing_tag (self , endtag ):
395
+ content = "<!-- not a comment --><i>Egg & Spam</i>"
396
+ s = f'<TitLe>{ content } </{ endtag } >'
397
+ self ._run_check (s , [("starttag" , "title" , []),
398
+ ('data' , '<!-- not a comment --><i>Egg & Spam</i>' ),
399
+ ("endtag" , "title" )],
400
+ collector = EventCollectorNoNormalize (convert_charrefs = True ))
401
+ self ._run_check (s , [("starttag" , "title" , []),
402
+ ('data' , '<!-- not a comment --><i>Egg ' ),
403
+ ('entityref' , 'amp' ),
404
+ ('data' , ' Spam</i>' ),
405
+ ("endtag" , "title" )],
406
+ collector = EventCollectorNoNormalize (convert_charrefs = False ))
407
+
408
+ @support .subTests ('endtag' , ['textarea' , 'TEXTAREA' , 'textarea ' , 'textarea\n ' ,
409
+ 'textarea/' , 'textarea foo=bar' , 'textarea foo=">"' ])
410
+ def test_textarea_closing_tag (self , endtag ):
411
+ content = "<!-- not a comment --><i>Egg & Spam</i>"
412
+ s = f'<TexTarEa>{ content } </{ endtag } >'
413
+ self ._run_check (s , [("starttag" , "textarea" , []),
414
+ ('data' , '<!-- not a comment --><i>Egg & Spam</i>' ),
415
+ ("endtag" , "textarea" )],
416
+ collector = EventCollectorNoNormalize (convert_charrefs = True ))
417
+ self ._run_check (s , [("starttag" , "textarea" , []),
418
+ ('data' , '<!-- not a comment --><i>Egg ' ),
419
+ ('entityref' , 'amp' ),
420
+ ('data' , ' Spam</i>' ),
421
+ ("endtag" , "textarea" )],
422
+ collector = EventCollectorNoNormalize (convert_charrefs = False ))
423
+
349
424
@support .subTests ('tail,end' , [
350
425
('' , False ),
351
426
('<' , False ),
@@ -363,6 +438,27 @@ def test_eof_in_script(self, tail, end):
363
438
("data" , content if end else content + tail )],
364
439
collector = EventCollectorNoNormalize (convert_charrefs = False ))
365
440
441
+ @support .subTests ('tail,end' , [
442
+ ('' , False ),
443
+ ('<' , False ),
444
+ ('</' , False ),
445
+ ('</t' , False ),
446
+ ('</title' , False ),
447
+ ('</title ' , True ),
448
+ ('</title foo=bar' , True ),
449
+ ('</title foo=">' , True ),
450
+ ])
451
+ def test_eof_in_title (self , tail , end ):
452
+ s = f'<TitLe>Egg & Spam{ tail } '
453
+ self ._run_check (s , [("starttag" , "title" , []),
454
+ ("data" , "Egg & Spam" + ('' if end else tail ))],
455
+ collector = EventCollectorNoNormalize (convert_charrefs = True ))
456
+ self ._run_check (s , [("starttag" , "title" , []),
457
+ ('data' , 'Egg ' ),
458
+ ('entityref' , 'amp' ),
459
+ ('data' , ' Spam' + ('' if end else tail ))],
460
+ collector = EventCollectorNoNormalize (convert_charrefs = False ))
461
+
366
462
def test_comments (self ):
367
463
html = ("<!-- I'm a valid comment -->"
368
464
'<!--me too!-->'
0 commit comments