From 55c9244baa4c56611a4971aa623b618e5ce4ef4f Mon Sep 17 00:00:00 2001 From: vedchaudhari Date: Sat, 24 Oct 2026 12:48:13 +0530 Subject: [PATCH] test: accept '?' from zipinfo in zip interop test Info-ZIP's fnfilter() prints bytes that isprint() rejects as '?'. Some builds that report UNICODE_SUPPORT still do this, for example Gentoo's without the natspec patch, so zipinfo lists the non-ASCII entry name as a row of '?' and the test fails. When the exact name is not in the listing, also accept it with the non-ASCII parts shown as '?'. The ASCII parts and the entry itself are still checked, and bsdtar still checks the exact name when extracting. Assisted-by: a closed-source coding agent Signed-off-by: vedchaudhari --- test/parallel/test-zlib-zip-interop.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-zlib-zip-interop.js b/test/parallel/test-zlib-zip-interop.js index 429f7b02973e..f8718d1e97a7 100644 --- a/test/parallel/test-zlib-zip-interop.js +++ b/test/parallel/test-zlib-zip-interop.js @@ -81,9 +81,18 @@ test('an archive written by createZipArchive is readable by unzip, zipinfo, and const zipinfo = spawnSync('zipinfo', [archivePath], { env }); assert.strictEqual(zipinfo.status, 0); + const listing = zipinfo.stdout.toString(); for (const name of Object.keys(files)) { - if (!zipinfoUnicode && /[^\x20-\x7e]/.test(name)) continue; - assert.ok(zipinfo.stdout.toString().includes(name), `zipinfo missing ${name}`); + if (listing.includes(name)) continue; + if (/[^\x20-\x7e]/.test(name)) { + if (!zipinfoUnicode) continue; + // Some zipinfo builds (e.g. Gentoo's without natspec) print bytes that + // isprint() rejects as '?' (fnfilter() in Info-ZIP's extract.c), which + // can leave invalid UTF-8 behind (U+FFFD once decoded). Accept that. + const placeholder = name.replace(/[^\x20-\x7e]+/g, '?'); + if (listing.replace(/[?\uFFFD]+/g, '?').includes(placeholder)) continue; + } + assert.fail(`zipinfo missing ${name}`); } const extractDir = path.join(dir, 'out');