From 049b2904256a367daac833921aed8f71dff88ad7 Mon Sep 17 00:00:00 2001 From: Shankar Karuppiah Date: Tue, 13 May 2014 09:48:19 +0300 Subject: [PATCH] Fixed jsonp transport getting close due parser error, when escaped new line sent over the socket --- lib/transports/polling-jsonp.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/transports/polling-jsonp.js b/lib/transports/polling-jsonp.js index 79022348b..d7f44dd73 100644 --- a/lib/transports/polling-jsonp.js +++ b/lib/transports/polling-jsonp.js @@ -17,6 +17,7 @@ module.exports = JSONPPolling; */ var rNewline = /\n/g; +var rEscapedNewline = /\\n/g; /** * Global JSONP callbacks. @@ -211,6 +212,8 @@ JSONPPolling.prototype.doWrite = function (data, fn) { initIframe(); // escape \n to prevent it from being converted into \r\n by some UAs + // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side + data = data.replace(rEscapedNewline, '\\\n'); this.area.value = data.replace(rNewline, '\\n'); try {