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

HTML characters are wrongly escaped #55

Closed
adarshmadrecha opened this issue Sep 26, 2020 · 1 comment
Closed

HTML characters are wrongly escaped #55

adarshmadrecha opened this issue Sep 26, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@adarshmadrecha
Copy link

Describe the bug
When using escaped characters like 
 and 
 in Js, they are converted to wrong characters in XML like 
 and 

Because of this, I am not able to add CRLF.

To Reproduce

const finalObj = {
     ENVELOPE: {
       HEADER: {
         TALLYREQUEST: "Line One 
 Line Two",
       },
    };
const doc = create(finalObj);
const xml = doc.end({ prettyPrint: true });
<!-- Currently it's generated like this  -->
<?xml version="1.0"?>
<ENVELOPE>
  <HEADER>
    <TALLYREQUEST>Line One &amp;#13;&amp;#10; Line Two</TALLYREQUEST>
  </HEADER>
</ENVELOPE>
<!-- What I Expect to generate  -->
<?xml version="1.0"?>
<ENVELOPE>
  <HEADER>
    <TALLYREQUEST>Line One &#13;&#10; Line Two</TALLYREQUEST>
  </HEADER>
</ENVELOPE>

Expected behavior
&#13; should remain &#13; and not get converted to &amp;#13;

Version:

  • node.js: [12.18.3]
  • xmlbuilder2 [2.4.0]

Additional context
The legacy application does not understand \n. Hence I want to use these characters ( &#13; and &#10;) as is.

@adarshmadrecha adarshmadrecha added the bug Something isn't working label Sep 26, 2020
@oozcitak
Copy link
Owner

oozcitak commented Oct 2, 2020

This is an XML builder not an HTML document builder. So &#13; has no special meaning in XML context. This behavior is expected.

That being said I understand the use case for your issue, so I have a suggestion. I am working on custom document serializers, which will allow you to convert your document into whatever format you like. This will allow you to not escape HTML characters. The issue is here if you would like to keep track: #47

@oozcitak oozcitak closed this as completed Oct 2, 2020
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

2 participants