fix(coding-agent): resolved UTF-8 corruption in bash executor output (#433)

- Fixed UTF-8 text corruption in bash executor by replacing Buffer.toString() with streaming TextDecoder.
This commit is contained in:
Can Bölük 2026-01-04 03:15:50 +01:00 committed by GitHub
parent 7e2a99b485
commit 6ddfd1be13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -97,11 +97,13 @@ export function executeBash(command: string, options?: BashExecutorOptions): Pro
options.signal.addEventListener("abort", abortHandler, { once: true });
}
const decoder = new TextDecoder();
const handleData = (data: Buffer) => {
totalBytes += data.length;
// Sanitize once at the source: strip ANSI, replace binary garbage, normalize newlines
const text = sanitizeBinaryOutput(stripAnsi(data.toString())).replace(/\r/g, "");
const text = sanitizeBinaryOutput(stripAnsi(decoder.decode(data, { stream: true }))).replace(/\r/g, "");
// Start writing to temp file if exceeds threshold
if (totalBytes > DEFAULT_MAX_BYTES && !tempFilePath) {