Skip to content

Error when using '<' and '>' in comment in doctype markup declaration list #530

@Cwazywierdo

Description

@Cwazywierdo
  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?

Description

Trying to parse comments containing '<' or '>' inside the DOCTYPE markup declaration list results in errors. The errors are different depending on whether '<' or '>' was used (or which appears first). This is not an issue if the comment is elsewhere in the file.

Code and output

const xmlStr = `
<!DOCTYPE greeting [
  <!-- < -->
  <!ELEMENT greeting (#PCDATA)>
]>
<greeting>Hello, world!</greeting>
`

const parser = new fxparser.XMLParser();
const output = parser.parse(xmlStr);

out:

Uncaught Error: Invalid DOCTYPE
    readDocType DocTypeReader.js:73
    parseXml OrderedObjParser.js:245
    parse XMLParser.js:35
DocTypeReader.js:73:26
const xmlStr = `
<!DOCTYPE greeting [
  <!-- > -->
  <!ELEMENT greeting (#PCDATA)>
]>
<greeting>Hello, world!</greeting>
`

const parser = new fxparser.XMLParser();
const output = parser.parse(xmlStr);

out:

Uncaught Error: Invalid XML comment in DOCTYPE
    readDocType DocTypeReader.js:82
    parseXml OrderedObjParser.js:245
    parse XMLParser.js:35
DocTypeReader.js:82:30

Probably not important, but I feel I should note that while the online version still throws errors, the error messages are different. '<' and '>' throw Error: Start tag expected.:1:undefined and Error: char 'E' is not expected.:3:5 respectively.

Would you like to work on this issue?

  • Yes
  • No

Bookmark this repository for further updates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    PendingPending to be confirmed by user/author for some check/update/implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions