1
0
Fork 0
mirror of https://github.com/engineer-man/piston.git synced 2025-04-22 13:06:27 +02:00

Merge pull request from Brikaa/base64

Include non-ascii in CLI binary checking
This commit is contained in:
Thomas Hobson 2022-02-24 18:54:48 +13:00 committed by GitHub
commit 1b76bd8d1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 <20> (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 {