@@ -466,26 +466,44 @@ static str parse_content(document* d)
466
466
// have found a </
467
467
break ;
468
468
}
469
- else if (peek_at (d , 1 ) == '!' && peek_at ( d , 2 ) == '-' && peek_at ( d , 3 ) == '-' )
469
+ else if (peek_at (d , 1 ) == '!' )
470
470
{
471
- skip (d , 3 );
472
- // you can't reuse the two '-' characters for the closing as well
473
- if (peek_at (d , 0 ) == '\0' || peek_at (d , 1 ) == '\0' )
471
+ if (peek_at (d , 2 ) == '-' && peek_at (d , 3 ) == '-' )
474
472
{
475
- set_error (d , "Didn't get a closing comment" );
476
- return start_end (0 , 0 );
477
- }
478
- skip (d , 2 );
479
- for (;;)
480
- {
481
- if (!find (d , '>' ))
473
+ skip (d , 3 );
474
+ // you can't reuse the two '-' characters for the closing as well
475
+ if (peek_at (d , 0 ) == '\0' || peek_at (d , 1 ) == '\0' )
482
476
{
483
477
set_error (d , "Didn't get a closing comment" );
484
478
return start_end (0 , 0 );
485
479
}
486
- skip (d , 1 );
487
- if (peek_at (d , -3 ) == '-' && peek_at (d , -2 ) == '-' )
488
- break ;
480
+ skip (d , 2 );
481
+ for (;;)
482
+ {
483
+ if (!find (d , '>' ))
484
+ {
485
+ set_error (d , "Didn't get a closing comment" );
486
+ return start_end (0 , 0 );
487
+ }
488
+ skip (d , 1 );
489
+ if (peek_at (d , -3 ) == '-' && peek_at (d , -2 ) == '-' )
490
+ break ;
491
+ }
492
+ } else if (d -> end - d -> cursor >= 9 && memcmp (d -> cursor + 2 , "[CDATA[" , 7 ) == 0 ) {
493
+ skip (d , 9 );
494
+ for (;;)
495
+ {
496
+ if (!find (d , '>' ))
497
+ {
498
+ set_error (d , "Didn't close CDATA" );
499
+ return start_end (0 , 0 );
500
+ }
501
+ skip (d , 1 );
502
+ if (peek_at (d , -3 ) == ']' && peek_at (d , -2 ) == ']' )
503
+ break ;
504
+ }
505
+ } else {
506
+ parse_tag (d );
489
507
}
490
508
}
491
509
else
0 commit comments