mirror of
https://github.com/engineer-man/piston.git
synced 2025-06-07 10:46:27 +02:00
Include non-ascii in cli binary checking
This commit is contained in:
parent
a965df2eb9
commit
37b5b02067
1 changed files with 2 additions and 1 deletions
|
@ -246,11 +246,12 @@ async function run_non_interactively(files, argv) {
|
||||||
exports.handler = async argv => {
|
exports.handler = async argv => {
|
||||||
const files = [...(argv.files || []), argv.file].map(file_path => {
|
const files = [...(argv.files || []), argv.file].map(file_path => {
|
||||||
const buffer = fs.readFileSync(file_path);
|
const buffer = fs.readFileSync(file_path);
|
||||||
|
// Checks for <20> (the replacement character) after encoding the buffer to uf8
|
||||||
const encoding =
|
const encoding =
|
||||||
(buffer
|
(buffer
|
||||||
.toString()
|
.toString()
|
||||||
.split('')
|
.split('')
|
||||||
.some(x => x.charCodeAt(0) >= 128) &&
|
.some(x => x.charCodeAt(0) === 65533) &&
|
||||||
'base64') ||
|
'base64') ||
|
||||||
'utf8';
|
'utf8';
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue