Skip to content

xml2json doesn't check if input XML is well-formed #36

@giulioturetta

Description

@giulioturetta

Calling xml2json method
curl -X POST --data-binary "$XML_INLINE" https://services.phaidra.univie.ac.at/api/rights/xml2json
where XML_INLINE content is a malformed XML (missing '<' in uwr:allow> tag)
<uwr:rights xmlns:uwr="http://phaidra.univie.ac.at/XML/V1.0/rights"> uwr:allow> <uwr:username expires="2017-04-06T09:11:51Z">hudakr4</uwr:username> <uwr:faculty>A0</uwr:faculty> <uwr:gruppe>3111</uwr:gruppe> <uwr:spl>21</uwr:spl> <uwr:perfunk>8129</uwr:perfunk> <uwr:gruppe>3112</uwr:gruppe> </uwr:allow> </uwr:rights>
fails silently.

Calling the same xml2json method with a slightly different malformed XML (truncated </uwr:user tag)
<uwr:rights xmlns:uwr="http://phaidra.univie.ac.at/XML/V1.0/rights"> <uwr:allow> <uwr:username expires="2017-04-06T09:11:51Z">hudakr4</uwr:user <uwr:faculty>A0</uwr:faculty> <uwr:gruppe>3111</uwr:gruppe> <uwr:spl>21</uwr:spl> <uwr:perfunk>8129</uwr:perfunk> <uwr:gruppe>3112</uwr:gruppe> </uwr:allow> </uwr:rights>
returns
{"metadata":{"alerts":[],"rights":{"username":[{"expires":"2017-04-06T09:11:51Z","value":"hudakr4<\/uwr:user\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t"}]}}}

It seems Mojo:DOM doesn't check if input XML is well-formed while parsing.

Expected behaviour
Check if input XML is well-formed before interpreting it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions