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