1
0
mirror of https://github.com/redis/node-redis.git synced 2025-12-12 21:21:15 +03:00

fix: multi-byte character corruption when converting Buffers to strings (#3100)

* add tests for multi-byte character buffer
* support multi-byte characters when decoding buffers

fixes: #2993
This commit is contained in:
Bob Burden III
2025-10-13 06:19:45 -04:00
committed by GitHub
parent 96d6445d66
commit d7c6544d3a
2 changed files with 19 additions and 6 deletions

View File

@@ -506,9 +506,8 @@ export class Decoder {
}
chunks.push(chunk.subarray(start, crlfIndex));
return type === Buffer ?
Buffer.concat(chunks) :
chunks.join('');
const buffer = Buffer.concat(chunks);
return type === Buffer ? buffer : buffer.toString();
}
#decodeBlobString(type, chunk) {
@@ -578,9 +577,8 @@ export class Decoder {
chunks.push(chunk.subarray(this.#cursor, end));
this.#cursor = end + skip;
return type === Buffer ?
Buffer.concat(chunks) :
chunks.join('');
const buffer = Buffer.concat(chunks);
return type === Buffer ? buffer : buffer.toString();
}
#decodeBlobStringWithLength(length, type, chunk) {