From 38a09e1a06a54b811d839ecc5ff7669663eba619 Mon Sep 17 00:00:00 2001 From: Yuki von Kanel Date: Fri, 29 May 2020 22:02:30 -0500 Subject: [PATCH] fix: _readyCheck INFO parser's handling of colon characters (#1127) This commit fixes an issue which would occur when encountering INFO response field values containing the colon character. Because the parser logic splits entire lines upon colon character delimiters and took only the first component as the field name, and second component as the field value, any line containing multiple colons would ultimately lead to an incorrectly truncated field value. For example: "config_file:Y:\\redis\\redis.conf" Would be split into: ["config_file", "Y", "\\redis\\redis.conf"] Leading to a field name of "config_file" and an incorrect field value of "Y". The resolution is simply to handle additional field value components as needed, joining them together appropriately. --- lib/redis/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/redis/index.ts b/lib/redis/index.ts index 8ec832e6..fae6eb9a 100644 --- a/lib/redis/index.ts +++ b/lib/redis/index.ts @@ -507,9 +507,10 @@ Redis.prototype._readyCheck = function (callback) { const lines = res.split("\r\n"); for (let i = 0; i < lines.length; ++i) { - const parts = lines[i].split(":"); - if (parts[1]) { - info[parts[0]] = parts[1]; + const [fieldName, ...fieldValueParts] = lines[i].split(":"); + const fieldValue = fieldValueParts.join(":"); + if (fieldValue) { + info[fieldName] = fieldValue; } }