xmlbuilder2
xmlbuilder2 copied to clipboard
Some XML entities not decoded when converting to other formats
Describe the bug
Entities like &
, >
, etc remain encoded when converting to eg object or json formats. Curiously, the quote entites ("
and '
) seem to translate fine
To Reproduce This is easy to reproduce during an interactive session:
> const create = require("xmlbuilder2").create;
undefined
> create("<test><test></test>").end({format: "json"});
'{"test":"<test>"}'
> create("<test>pb&j</test>").end({format: "json"})
'{"test":"pb&j"}'
> create("<test>"double quotes"</test>").end({format: "json"})
'{"test":"\\"double quotes\\""}'
> create("<test>'single quotes'</test>").end({format: "json"})
`{"test":"'single quotes'"}`
> create().ele("test").txt("pb&j").end({format: "xml"})
'<?xml version="1.0"?><test>pb&j</test>'
> create(create().ele("test").txt("pb&j").end({format: "xml"})).end({format: "object"})
{ test: 'pb&j' }
Expected behavior
I expect &
to translate to &
, >
to translate to >
, etc
Version:
- node.js: 14.17.1
- xmlbuilder2: 3.0.2