fix(native): reject trailing text in lipo integers and keep multi-word otool keys (#531)

This commit is contained in:
morluto
2026-10-05 15:23:02 +08:00
committed by GitHub
parent c30878f616
commit 9e30d93af3
4 changed files with 26 additions and 2 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ export const parseLipoArchitectures = (output: string): LipoArchitecture[] => {
};
const integer = (value: string | undefined): number | null => {
if (value === undefined) return null;
if (value === undefined || !/^\d+$/u.test(value)) return null;
const parsed = Number.parseInt(value, 10);
return Number.isSafeInteger(parsed) && parsed >= 0 ? parsed : null;
};
+1 -1
View File
@@ -167,7 +167,7 @@ const parseFields = (block: string): Record<string, string | number | null> => {
const fields: Record<string, string | number | null> = {};
for (const rawLine of block.split(/\r?\n/u).slice(1)) {
const line = rawLine.trim();
const match = /^(\S+(?:\s+version)?)\s+(.+)$/u.exec(line);
const match = /^(\S+(?:\s+(?:version|stamp))?)\s+(.+)$/u.exec(line);
if (match?.[1] === undefined || match[2] === undefined) continue;
const value = match[2].trim();
fields[match[1]] = numeric(value) ?? value;