Skip to content

Commit

Permalink
fix: _readyCheck INFO parser's handling of colon characters (#1127)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Rua-Yuki committed May 30, 2020
1 parent 1d4330d commit 38a09e1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/redis/index.ts
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 38a09e1

Please sign in to comment.