From 4cae0672114cf4012788f13e83285513d8211ebd Mon Sep 17 00:00:00 2001 From: Martin Dirichs Date: Fri, 3 Mar 2017 15:00:46 +0100 Subject: [PATCH 1/5] Corrected the way basic authtication parameters are supplied to HttpClient --- lib/proxy.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/proxy.js b/lib/proxy.js index b0b3b86..a260dfa 100644 --- a/lib/proxy.js +++ b/lib/proxy.js @@ -48,11 +48,7 @@ Proxy.prototype.invoke = function(method, args, callback) { }; if (this.username) { - options.auth = { - user: this.username, - pass: this.password, - sendImmediately: true - }; + options.auth = this.username + ':' + this.password; } var req = require(this.protocol).request(options, function(res) { @@ -87,4 +83,4 @@ Proxy.prototype.invoke = function(method, args, callback) { }; -module.exports = Proxy; \ No newline at end of file +module.exports = Proxy; From 513c797e9f3d0cd201c329e9727b8a498091aaa4 Mon Sep 17 00:00:00 2001 From: Martin Dirichs Date: Thu, 9 Mar 2017 17:43:18 +0100 Subject: [PATCH 2/5] Corrected handling of double values with up to three decimal places (code 0x5f) --- lib/reader2.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/reader2.js b/lib/reader2.js index 6c22e07..cddfcc4 100644 --- a/lib/reader2.js +++ b/lib/reader2.js @@ -389,9 +389,11 @@ Reader.prototype.readDouble = function(data) { return this.reader.nextInt8(); else if (code === 0x5e) return this.reader.nextInt16BE(); - else if (code === 0x5f) - return this.reader.nextFloatBE(); - else if (code === 0x44) { + else if (code === 0x5f) { + // While the specification suggests reading a FloatBE here, + // this is the way how it's handled by the Java implementation + return this.reader.nextInt32BE() * 0.001; + } else if (code === 0x44) { return this.reader.nextDoubleBE(); } }; From bb5527d29a4c417e0e8036babe0e27014d4dbd1c Mon Sep 17 00:00:00 2001 From: Martin Dirichs Date: Wed, 29 Mar 2017 09:27:19 +0200 Subject: [PATCH 3/5] Corrected handling of UTF8 encoded string; this addition is inspired by a contribution of pandazki --- lib/reader2.js | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/reader2.js b/lib/reader2.js index cddfcc4..0295523 100644 --- a/lib/reader2.js +++ b/lib/reader2.js @@ -229,6 +229,33 @@ Reader.prototype.readClassDef = function(data) { } }; +Reader.prototype.readUTF8String = function(len) { + + if (len === 0) + return ""; + + var startPos = this.reader.tell(), byteLength; + + while (len--) { + var head = this.reader.nextUInt8(); + if (head < 0x80) { + continue; + } else if ((head & 0xe0) === 0xc0) { + this.reader.move(1); + } else if ((head & 0xf0) === 0xe0) { + this.reader.move(2); + } else if ((head & 0xf8) === 0xf0) { + this.reader.move(3); + } else { + throw new Error("String is not in valid UTF-8 format"); + } + } + + byteLength = this.reader.tell() - startPos; + this.reader.seek(startPos); + + return this.reader.nextString(byteLength, 'utf8'); +} Reader.prototype.readString = function(data) { if (data) @@ -236,17 +263,17 @@ Reader.prototype.readString = function(data) { var code = this.reader.nextUInt8(); if (code >= 0 && code < 32) { - return this.reader.nextString(code); + return this.readUTF8String(code); } else if (code >= 0x30 && code <= 0x33) { this.reader.move(-1); var len = this.reader.nextUInt16BE() - 0x3000; - return this.reader.nextString(len); + return this.readUTF8String(len); } else if (code === 0x53) { var len = this.reader.nextUInt16BE(); - return this.reader.nextString(len); + return this.readUTF8String(len); } else if (code === 0x52) { var len = this.reader.nextUInt16BE(); - return this.reader.nextString(len) + this.readString(); + return this.readUTF8String(len) + this.readString(); } }; From 59150d2e6649248078e9c0b1539c6192a783855b Mon Sep 17 00:00:00 2001 From: Martin Dirichs Date: Fri, 26 Nov 2021 16:40:49 +0100 Subject: [PATCH 4/5] Using ISO-8859-1 character encoding for Basic Authentication now --- lib/proxy.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/proxy.js b/lib/proxy.js index a260dfa..e72c5fc 100644 --- a/lib/proxy.js +++ b/lib/proxy.js @@ -48,7 +48,9 @@ Proxy.prototype.invoke = function(method, args, callback) { }; if (this.username) { - options.auth = this.username + ':' + this.password; + // Use iso-8859-1 character encoding for basic authentication parameters + options.headers['Authorization'] = 'Basic ' + + Buffer.from(this.username + ':' + this.password, 'latin1').toString('base64'); } var req = require(this.protocol).request(options, function(res) { From 4919b3f1c09678207b83677f46ebf2a0ecdb83db Mon Sep 17 00:00:00 2001 From: dirichs Date: Fri, 17 Jan 2025 15:59:20 +0100 Subject: [PATCH 5/5] Corrected type specification for lists and maps. --- lib/writer2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/writer2.js b/lib/writer2.js index 5cde437..de43c4b 100644 --- a/lib/writer2.js +++ b/lib/writer2.js @@ -366,11 +366,11 @@ Writer.prototype.writeList = function(data) { }; Writer.prototype.writeType = function(data) { - this.writeString(data); if (this.typeRefs.hasOwnProperty(data)) { this.writeInt(this.typeRefs[data]); } else { this.typeRefs[data] = Object.keys(this.typeRefs).length; + this.writeString(data); } return this; }; @@ -388,4 +388,4 @@ function cap(str) { return str.charAt(0).toUpperCase() + str.slice(1); } -module.exports = Writer; \ No newline at end of file +module.exports = Writer;