aacerox / node-rest-client

REST API client from node.js
MIT License
376 stars 132 forks source link

Remove possible Unicode BOM from JSON data #197

Open rprinz08 opened 5 years ago

rprinz08 commented 5 years ago

Sometimes, services send JSON data which includes a BOM (https://de.wikipedia.org/wiki/Byte_Order_Mark) which is wrong (according to https://tools.ietf.org/html/rfc7159#section-8.1 second paragraph) but break things as node-rest-client throws an exception when calling JSON.parse. This patch tries to remove UTF-8/16/32 BOMs before this to be more robust against such services.