From 1541e382e490b21406317fc9bacce70e7b3ce60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20L=C3=A9caud=C3=A9?= Date: Tue, 2 Aug 2016 12:32:49 -0400 Subject: [PATCH] Fix escapce character catch in TCPGet + support 0x?? sequences --- nodes/core/io/31-tcpin.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index 12c4e4f20..f20f575f4 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -394,10 +394,20 @@ module.exports = function(RED) { if (this.out != "char") { this.splitc = Number(this.splitc); } else { - this.splitc = this.splitc.replace("\\n",0x0A).replace("\\r",0x0D).replace("\\t",0x09).replace("\\e",0x1B).replace("\\f",0x0C).replace("\\0",0x00); - if (typeof this.splitc == "string") { this.splitc = this.splitc.charCodeAt(0); } + if (this.splitc[0] == '\\') { + this.splitc = parseInt(this.splitc.replace("\\n",0x0A).replace("\\r",0x0D).replace("\\t",0x09).replace("\\e",0x1B).replace("\\f",0x0C).replace("\\0",0x00)); + } + + if (typeof this.splitc == "string") { + if (this.splitc.substr(0,2) == "0x") { + this.splitc = parseInt(this.splitc); + } + else { + this.splitc = this.splitc.charCodeAt(0); + } + } } // jshint ignore:line - + var buf; if (this.out == "count") { if (this.splitc === 0) { buf = new Buffer(1); }