Skip to content

Some character reference formats not parsed correctly #568

Open
@Pharb

Description

@Pharb
  • 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

According to this XML spec, character references can include leading zeros and lower-case letters in hexadecimal representation.

Personally I encountered this parsing issue by consuming XML provided by a proprietary third-party tool, which includes references in the style of <.

Input

<?xml version="1.0"?>
<tests>
  <test>&lt;</test>
  <test>&#60;</test>
  <test>&#060;</test>
  <test>&#0060;</test>
  <test>&#x3C;</test>
  <test>&#x03C;</test>
  <test>&#x003C;</test>
  <test>&#x3c;</test>
  <test>&#x03c;</test>
  <test>&#x003c;</test>
</tests>

Code

const parser = new XMLParser();
let result = parser.parse(xmlData, true);

Output

{
    "?xml": "",
    "tests": {
        "test": [
            "<",
            "<",
            "&#060;",
            "&#0060;",
            "<",
            "&#x03C;",
            "&#x003C;",
            "&#x3c;",
            "&#x03c;",
            "&#x003c;"
        ]
    }
}

expected data

{
    "?xml": "",
    "tests": {
        "test": [
            "<",
            "<",
            "<",
            "<",
            "<",
            "<",
            "<",
            "<",
            "<",
            "<",
        ]
    }
}

Would you like to work on this issue?

  • Yes

Bookmark this repository for further updates. Visit SoloThought to know about recent features.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions