From 7489c134f712eaf5d003ce40cc8223c41e05e3fa Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 31 Dec 2005 01:47:57 +0100 Subject: [PATCH] Make non-terminated comments and cdata sections have 'the rest' as content --- src/dom/sgml/scanner.c | 10 ++++++++-- src/dom/test/test-sgml-parser-basic | 21 +++++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/dom/sgml/scanner.c b/src/dom/sgml/scanner.c index 0da143c64..34fb141d7 100644 --- a/src/dom/sgml/scanner.c +++ b/src/dom/sgml/scanner.c @@ -205,7 +205,10 @@ skip_comment(struct dom_scanner *scanner, unsigned char **string) } } - if (!pos) pos = scanner->end; + if (!pos) { + pos = scanner->end; + length = pos - *string; + } *string = pos; return length; @@ -227,7 +230,10 @@ skip_cdata_section(struct dom_scanner *scanner, unsigned char **string) } } - if (!pos) pos = scanner->end; + if (!pos) { + pos = scanner->end; + length = pos - *string; + } *string = pos; return length; diff --git a/src/dom/test/test-sgml-parser-basic b/src/dom/test/test-sgml-parser-basic index c9ba46775..58635e8eb 100755 --- a/src/dom/test/test-sgml-parser-basic +++ b/src/dom/test/test-sgml-parser-basic @@ -64,17 +64,18 @@ element: root test_output_equals \ 'Parse comment combinations.' \ -'' \ +'' \ ' element: root #comment: ' \ +'Parse bad comment.' \ +'s' \ ' -#comment: foo' +#comment: ->s' test_output_equals \ 'Parse an enclosed CDATA section.' \ @@ -83,6 +84,18 @@ test_output_equals \ element: root #cdata-section: ...] ]>...' +test_output_equals \ +'Parse non-enclosed CDATA section.' \ +'' \ +' +#cdata-section: ...' + +test_output_equals \ +'Parse a bad CDATA section.' \ +'' \