Skip to content

ParseError: Not well-formed XML starting with "<!" when doctype is lowercased #817

Description

@WesselKroos

Describe the bug
A ParseError: Not well-formed XML starting with "<!" is thrown when the doctype is lowercased and the mimetype is text/html.

To Reproduce
@xmldom/[email protected] fails: https://stackblitz.com/edit/js-xmldom-template-4yhw372e?file=index.js
@xmldom/[email protected] fails: https://stackblitz.com/edit/js-xmldom-template-myp4xtfp?file=index.js
@xmldom/[email protected] succeeds: https://stackblitz.com/edit/js-xmldom-template-wzm3upeq?file=index.js
Thus this seems like a regression introduced in xmldom/[email protected]

Expected behavior
A lower cased doctype should be parsed correctly.
According to the html spec the doctype is a string that is an ASCII case-insensitive match for the string "<!DOCTYPE".
The W3C Markup validator allows lowercased doctypes.
Examples of websites with a lowercased doctype are google.com and addons.opera.com.

Versions:
Affected @xmldom/xmldom versions: 0.9.0 - 0.9.6

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdoctypeeverything related to doctype parsing and DTDspec:HTMLxml:well-formedhttps://www.w3.org/TR/xml11/#dt-wellformed

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions