Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some XML entities not decoded when converting to other formats #142

Closed
pkmnfrk opened this issue Jun 15, 2022 · 2 comments
Closed

Some XML entities not decoded when converting to other formats #142

pkmnfrk opened this issue Jun 15, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@pkmnfrk
Copy link

pkmnfrk commented Jun 15, 2022

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>&lt;test&gt;</test>").end({format: "json"});
'{"test":"&lt;test&gt;"}'
> create("<test>pb&amp;j</test>").end({format: "json"})
'{"test":"pb&amp;j"}'
> create("<test>&quot;double quotes&quot;</test>").end({format: "json"})
'{"test":"\\"double quotes\\""}'
> create("<test>&apos;single quotes&apos;</test>").end({format: "json"})
`{"test":"'single quotes'"}`

> create().ele("test").txt("pb&j").end({format: "xml"})
'<?xml version="1.0"?><test>pb&amp;j</test>'
> create(create().ele("test").txt("pb&j").end({format: "xml"})).end({format: "object"})
{ test: 'pb&amp;j' }

Expected behavior
I expect &amp; to translate to &, &gt; to translate to >, etc

Version:

  • node.js: 14.17.1
  • xmlbuilder2: 3.0.2
@pkmnfrk pkmnfrk added the bug Something isn't working label Jun 15, 2022
@Nooxlock
Copy link

Any update on this issue? Trying to find a temporary solution but with little to no success...

@universalhandle
Copy link
Collaborator

This looks like a duplicate of various issues that have been opened related to ampersand encoding (see #105, #109, #110). I believe this to be fixed with the release of v3.1.0. Please reopen if you can still reproduce after upgrading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants