update electron to v43
All checks were successful
Android Build / publish (push) Successful in 55s
Linux Build / publish (push) Successful in 1m6s

This commit is contained in:
olcxja 2026-07-09 22:38:33 +02:00
commit fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions

View file

@ -1,24 +1,20 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBinaryFileSync = exports.isBinaryFile = void 0;
const fs = require("fs");
const util_1 = require("util");
const statAsync = util_1.promisify(fs.stat);
const openAsync = util_1.promisify(fs.open);
const closeAsync = util_1.promisify(fs.close);
const statAsync = (0, util_1.promisify)(fs.stat);
const openAsync = (0, util_1.promisify)(fs.open);
const closeAsync = (0, util_1.promisify)(fs.close);
const MAX_BYTES = 512;
const UTF8_BOUNDARY_RESERVE = 3;
// A very basic non-exception raising reader. Read bytes and
// at the end use hasError() to check whether this worked.
class Reader {
fileBuffer;
size;
offset;
error;
constructor(fileBuffer, size) {
this.fileBuffer = fileBuffer;
this.size = size;
@ -38,6 +34,10 @@ class Reader {
next(len) {
const n = new Array();
for (let i = 0; i < len; i++) {
// Stop reading if an error occurred
if (this.error) {
return n;
}
n[i] = this.nextByte();
}
return n;
@ -53,6 +53,11 @@ function readProtoVarInt(reader) {
if ((b & 0x80) === 0) {
break;
}
if (idx >= 10) {
// Varint can be between 1 and 10 bytes. This is too large.
reader.error = true;
break;
}
idx++;
}
return varInt;
@ -95,34 +100,37 @@ function isBinaryProto(fileBuffer, totalBytes) {
}
return numMessages > 0;
}
function isBinaryFile(file, size) {
return __awaiter(this, void 0, void 0, function* () {
if (isString(file)) {
const stat = yield statAsync(file);
isStatFile(stat);
const fileDescriptor = yield openAsync(file, 'r');
const allocBuffer = Buffer.alloc(MAX_BYTES);
// Read the file with no encoding for raw buffer access.
// NB: something is severely wrong with promisify, had to construct my own Promise
return new Promise((fulfill, reject) => {
fs.read(fileDescriptor, allocBuffer, 0, MAX_BYTES, 0, (err, bytesRead, _) => {
closeAsync(fileDescriptor);
if (err) {
reject(err);
}
else {
async function isBinaryFile(file, size) {
if (isString(file)) {
const stat = await statAsync(file);
isStatFile(stat);
const fileDescriptor = await openAsync(file, 'r');
const allocBuffer = Buffer.alloc(MAX_BYTES + UTF8_BOUNDARY_RESERVE);
// Read the file with no encoding for raw buffer access.
// NB: something is severely wrong with promisify, had to construct my own Promise
return new Promise((fulfill, reject) => {
fs.read(fileDescriptor, allocBuffer, 0, MAX_BYTES + UTF8_BOUNDARY_RESERVE, 0, (err, bytesRead, _) => {
closeAsync(fileDescriptor);
if (err) {
reject(err);
}
else {
try {
fulfill(isBinaryCheck(allocBuffer, bytesRead));
}
});
catch (error) {
reject(error);
}
}
});
});
}
else {
if (size === undefined) {
size = file.length;
}
else {
if (size === undefined) {
size = file.length;
}
return isBinaryCheck(file, size);
}
});
return isBinaryCheck(file, size);
}
}
exports.isBinaryFile = isBinaryFile;
function isBinaryFileSync(file, size) {
@ -130,8 +138,8 @@ function isBinaryFileSync(file, size) {
const stat = fs.statSync(file);
isStatFile(stat);
const fileDescriptor = fs.openSync(file, 'r');
const allocBuffer = Buffer.alloc(MAX_BYTES);
const bytesRead = fs.readSync(fileDescriptor, allocBuffer, 0, MAX_BYTES, 0);
const allocBuffer = Buffer.alloc(MAX_BYTES + UTF8_BOUNDARY_RESERVE);
const bytesRead = fs.readSync(fileDescriptor, allocBuffer, 0, MAX_BYTES + UTF8_BOUNDARY_RESERVE, 0);
fs.closeSync(fileDescriptor);
return isBinaryCheck(allocBuffer, bytesRead);
}
@ -149,7 +157,8 @@ function isBinaryCheck(fileBuffer, bytesRead) {
return false;
}
let suspiciousBytes = 0;
const totalBytes = Math.min(bytesRead, MAX_BYTES);
const totalBytes = Math.min(bytesRead, MAX_BYTES + UTF8_BOUNDARY_RESERVE);
const scanBytes = Math.min(totalBytes, MAX_BYTES);
// UTF-8 BOM
if (bytesRead >= 3 && fileBuffer[0] === 0xef && fileBuffer[1] === 0xbb && fileBuffer[2] === 0xbf) {
return false;
@ -190,37 +199,49 @@ function isBinaryCheck(fileBuffer, bytesRead) {
if (bytesRead >= 2 && fileBuffer[0] === 0xff && fileBuffer[1] === 0xfe) {
return false;
}
for (let i = 0; i < totalBytes; i++) {
for (let i = 0; i < scanBytes; i++) {
if (fileBuffer[i] === 0) {
// NULL byte--it's binary!
return true;
}
else if ((fileBuffer[i] < 7 || fileBuffer[i] > 14) && (fileBuffer[i] < 32 || fileBuffer[i] > 127)) {
// UTF-8 detection
if (fileBuffer[i] > 193 && fileBuffer[i] < 224 && i + 1 < totalBytes) {
if (fileBuffer[i] >= 0xc0 && fileBuffer[i] <= 0xdf && i + 1 < totalBytes) {
i++;
if (fileBuffer[i] > 127 && fileBuffer[i] < 192) {
if (fileBuffer[i] >= 0x80 && fileBuffer[i] <= 0xbf) {
continue;
}
}
else if (fileBuffer[i] > 223 && fileBuffer[i] < 240 && i + 2 < totalBytes) {
else if (fileBuffer[i] >= 0xe0 && fileBuffer[i] <= 0xef && i + 2 < totalBytes) {
i++;
if (fileBuffer[i] > 127 && fileBuffer[i] < 192 && fileBuffer[i + 1] > 127 && fileBuffer[i + 1] < 192) {
if (fileBuffer[i] >= 0x80 && fileBuffer[i] <= 0xbf && fileBuffer[i + 1] >= 0x80 && fileBuffer[i + 1] <= 0xbf) {
i++;
continue;
}
}
else if (fileBuffer[i] >= 0xf0 && fileBuffer[i] <= 0xf7 && i + 3 < totalBytes) {
i++;
if (fileBuffer[i] >= 0x80 &&
fileBuffer[i] <= 0xbf &&
fileBuffer[i + 1] >= 0x80 &&
fileBuffer[i + 1] <= 0xbf &&
fileBuffer[i + 2] >= 0x80 &&
fileBuffer[i + 2] <= 0xbf) {
i += 2;
continue;
}
}
suspiciousBytes++;
// Read at least 32 fileBuffer before making a decision
if (i >= 32 && (suspiciousBytes * 100) / totalBytes > 10) {
if (i >= 32 && (suspiciousBytes * 100) / scanBytes > 10) {
return true;
}
}
}
if ((suspiciousBytes * 100) / totalBytes > 10) {
if ((suspiciousBytes * 100) / scanBytes > 10) {
return true;
}
if (suspiciousBytes > 1 && isBinaryProto(fileBuffer, totalBytes)) {
if (suspiciousBytes > 1 && isBinaryProto(fileBuffer, scanBytes)) {
return true;
}
return false;