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.' \ +'' \