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

Xml Pretty Print Not Working #128

Open
Stevoni opened this issue Jul 29, 2022 · 1 comment
Open

Xml Pretty Print Not Working #128

Stevoni opened this issue Jul 29, 2022 · 1 comment

Comments

@Stevoni
Copy link

Stevoni commented Jul 29, 2022

After submitting a simple XML request to Webhook cloud, the XML pretty print is not applied.

Request:

curl --location --request GET 'https://webhook.site/[guid]' \
--header 'Content-Type: text/xml' \
--data-raw '<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don'\''t forget me this weekend!</body>
</note>'

image

I noticed this originally because SOAP requests are not formatted.

@mavaddat
Copy link

mavaddat commented Jun 21, 2023

It looks like this is the logic responsible for pretty-printing XML:

content = prettyData.xml(content);

The Node package used for pretty-printing is called pretty-data. It is possible to test their solution on the project website: http://www.eslinstructor.net/pretty-data/
Using the data you provided results in the desired pretty printing:
vkBeautify - javascript plugin Screenshot
It appears the issue is that we are ignoring the content type specified by the Content-Type header field and instead relying on highlightjs to detect the type.
let hloutput = hljs.highlightAuto(content);

Perhaps because the XML snippet is not valid XML, the highlightjs isn't recognizing it as XML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants