chalettu / pushwoosh-nodejs

This is a node module I created to help consume Pushwoosh services in NodeJS
11 stars 5 forks source link

server crash when sending hebrew charecters #5

Open oriefrati opened 9 years ago

oriefrati commented 9 years ago

I'm using sails js and when i send push message in hebrew i get the following errors:

undefined:0

^ SyntaxError: Unexpected end of input at Object.parse (native) at IncomingMessage. (XXX/node_modules/pushwoosh/index.js:123:31) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:944:16 at process._tickDomainCallback (node.js:492:13)

CFA2k commented 9 years ago

I had the same problem. Try the following.

index.js line 100:

var jsonString = JSON.stringify(json_request);

change to:

var jsonString = JSON.stringify(json_request).replace(/[\u0080-\uFFFF]/g, function(m) { return "\\u" + ("0000" + m.charCodeAt(0).toString(16)).slice(-4); });

Works for me.

Source: https://community.pushwoosh.com/questions/1011/status-400-bad-request-when-sending-special-symbols