Skip to content

Incorrect escaping of XML special characters #425

@pokle

Description

@pokle

dasel appears to not escape XML special characters like <, > and & when emiting XML.

For example, echo '{"<": "<", ">": ">", "&": "&"}' | dasel -r json -w xml emits:

<doc>
  <&>&</&>
  <<><</<>
  <>>></>>
</doc>

which is invalid XML. Even dasel can't parse it again:

echo '{"<": "<", ">": ">", "&": "&"}' | dasel -r json -w xml | dasel -r xml
Error: could not unmarshal data: xml.Decoder.Token() - XML syntax error on line 2: expected element name after <

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions