From 88349b582b56194dfb31cd0a90bfb1307374cd64 Mon Sep 17 00:00:00 2001 From: mintrigue Date: Thu, 10 Oct 2013 11:29:35 -0700 Subject: [PATCH] Properly escape backslash in sync post body (updated) If the body of a post contained a backslash, it would be treated as an escape character when written to res.write('\') and corrupts the contents of the body. This patch properly escapes the backslash character. Update: removed extra period from previous pull request --- lib/XMLHttpRequest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/XMLHttpRequest.js b/lib/XMLHttpRequest.js index ad4f5f3..e339fd6 100644 --- a/lib/XMLHttpRequest.js +++ b/lib/XMLHttpRequest.js @@ -477,7 +477,7 @@ exports.XMLHttpRequest = function() { + "fs.writeFileSync('" + contentFile + "', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');" + "fs.unlinkSync('" + syncFile + "');" + "});" - + (data ? "req.write('" + data.replace(/'/g, "\\'") + "');":"") + + (data ? "req.write('" + data.replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "');":"") + "req.end();"; // Start the other Node Process, executing this string var syncProc = spawn(process.argv[0], ["-e", execString]);