From 9234a7c97c6b3e232019c99c8ab4e0015d70b461 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 26 Apr 2017 16:58:12 +0200 Subject: [PATCH] :bug: dont call iconv with unsupported encodings fixes #25359 --- extensions/git/src/git.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index cf2a7224f71..4adc617a3eb 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -171,6 +171,9 @@ async function exec(child: cp.ChildProcess, options: any = {}): Promise ee.removeListener(name, fn))); }; + let encoding = options.encoding || 'utf8'; + encoding = iconv.encodingExists(encoding) ? encoding : 'utf8'; + const [exitCode, stdout, stderr] = await Promise.all([ new Promise((c, e) => { once(child, 'error', e); @@ -179,7 +182,7 @@ async function exec(child: cp.ChildProcess, options: any = {}): Promise(c => { const buffers: Buffer[] = []; on(child.stdout, 'data', b => buffers.push(b)); - once(child.stdout, 'close', () => c(iconv.decode(Buffer.concat(buffers), options.encoding || 'utf8'))); + once(child.stdout, 'close', () => c(iconv.decode(Buffer.concat(buffers), encoding))); }), new Promise(c => { const buffers: Buffer[] = [];