insomnia-mockbin
insomnia-mockbin copied to clipboard
Invalid character in message
if there are some invalid characters in request body, a page with stack trace opens like at this url and and It is impossible to go back to Bin view to view other requests.
Opening bin url displays a blank page.
Error: Invalid character () in string: { \"ssid\": \"value\", \"message\" : \"msg\", \"time\" : \"9999\" }[D[D at index 67
at XMLStringifier.module.exports.XMLStringifier.assertLegalChar (/app/node_modules/mockbin/node_modules/xmlbuilder/lib/XMLStringifier.js:150:15)
at XMLStringifier.assertLegalChar (/app/node_modules/mockbin/node_modules/xmlbuilder/lib/XMLStringifier.js:4:59)
at XMLStringifier.module.exports.XMLStringifier.eleText (/app/node_modules/mockbin/node_modules/xmlbuilder/lib/XMLStringifier.js:27:19)
at new XMLText (/app/node_modules/mockbin/node_modules/xmlbuilder/lib/XMLText.js:19:35)
at XMLElement.module.exports.XMLNode.text (/app/node_modules/mockbin/node_modules/xmlbuilder/lib/XMLNode.js:168:15)
at XMLElement.module.exports.XMLNode.node (/app/node_modules/mockbin/node_modules/xmlbuilder/lib/XMLNode.js:160:15)
at XMLElement.module.exports.XMLNode.element (/app/node_modules/mockbin/node_modules/xmlbuilder/lib/XMLNode.js:103:28)
at XMLElement.module.exports.XMLNode.element (/app/node_modules/mockbin/node_modules/xmlbuilder/lib/XMLNode.js:90:30)
at XMLElement.module.exports.XMLNode.element (/app/node_modules/mockbin/node_modules/xmlbuilder/lib/XMLNode.js:87:25)
at XMLElement.module.exports.XMLNode.element (/app/node_modules/mockbin/node_modules/xmlbuilder/lib/XMLNode.js:87:25)
thanks for reporting.
@junaidk seems like an encoding problem.
can you please paste the body you're using here?
this is the message body { \"ssid\": \"value\", \"message\" : \"msg\", \"time\" : \"9999\" }^[[D^[[D
. It has left arraow key
chars at the end.
It starts show error page after receiving this message. And there is no way to go back to Bin
.
related to encoding by xmlbuilder in https://github.com/Mashape/mockbin/blob/master/src/middleware/negotiate-content.js#L49
My use case was emojis, althought it was valid json it would throw on this line. According to the module author it can be allowed by adding the {allowSurrogateChars: true}
flag to the call. In my case i was handling the instagram api which is sprinkled with emojis and other special characters.
I tested with the string above and it now doesn't throw invalid and renders fine.
https://github.com/oozcitak/xmlbuilder-js/issues/98 https://github.com/oozcitak/xmlbuilder-js/pull/29
Pull request in #40
thanks @stanzheng
np. great small tool for my prototyping.
this bin view use to crash on render but after applying the fix it works just fine.
http://mockbin-stanzheng.herokuapp.com/bin/02617471-83e0-4243-b5d7-43709197e3ad/log#entry-99