From 37b5b02067387ca617073750420848272779db0e Mon Sep 17 00:00:00 2001 From: Omar Brikaa Date: Sun, 30 Jan 2022 14:47:06 +0200 Subject: [PATCH] Include non-ascii in cli binary checking --- cli/commands/execute.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/commands/execute.js b/cli/commands/execute.js index 0d906bc..ee468cf 100644 --- a/cli/commands/execute.js +++ b/cli/commands/execute.js @@ -246,11 +246,12 @@ async function run_non_interactively(files, argv) { exports.handler = async argv => { const files = [...(argv.files || []), argv.file].map(file_path => { const buffer = fs.readFileSync(file_path); + // Checks for � (the replacement character) after encoding the buffer to uf8 const encoding = (buffer .toString() .split('') - .some(x => x.charCodeAt(0) >= 128) && + .some(x => x.charCodeAt(0) === 65533) && 'base64') || 'utf8'; return {