webhook.site icon indicating copy to clipboard operation
webhook.site copied to clipboard

Xml Pretty Print Not Working

Open Stevoni opened this issue 3 years ago • 1 comments

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.

Stevoni avatar Jul 29 '22 00:07 Stevoni

It looks like this is the logic responsible for pretty-printing XML: https://github.com/webhooksite/webhook.site/blob/605a331df5c9fd9303ec8aff4f4aec16f92a4068/resources/assets/js/app.js#L638 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. https://github.com/webhooksite/webhook.site/blob/605a331df5c9fd9303ec8aff4f4aec16f92a4068/resources/assets/js/app.js#L632 Perhaps because the XML snippet is not valid XML, the highlightjs isn't recognizing it as XML.

mavaddat avatar Jun 21 '23 18:06 mavaddat