Skip to content

Commit dd425b7

Browse files
authored
test: fix zipinfo non-ascii check in test-zlib-zip-interop
Keep UNICODE_SUPPORT guard so macOS skips checking non-ASCII names in zipinfo output, and accept '?' / U+FFFD placeholders on builds with UNICODE_SUPPORT that filter non-ASCII bytes in fnfilter() without wide-character printing support (such as NixOS or Gentoo). Fixes: #66975 Signed-off-by: Ravi Arnan <raviarnankeren@gmail.com> PR-URL: #66978 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Philipp Dunkel <pip@pipobscure.com>
1 parent 273f217 commit dd425b7

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎test/parallel/test-zlib-zip-interop.js‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,19 @@ test('an archive written by createZipArchive is readable by unzip, zipinfo, and
8181

8282
const zipinfo = spawnSync('zipinfo', [archivePath], { env });
8383
assert.strictEqual(zipinfo.status, 0);
84+
const zipinfoOut = zipinfo.stdout.toString();
8485
for (const name of Object.keys(files)) {
85-
if (!zipinfoUnicode && /[^\x20-\x7e]/.test(name)) continue;
86-
assert.ok(zipinfo.stdout.toString().includes(name), `zipinfo missing ${name}`);
86+
if (zipinfoOut.includes(name)) continue;
87+
// Info-ZIP's zipinfo replaces non-ASCII bytes with '?' unless built with
88+
// wide-character support (e.g. natspec or alt-iconv-utf8-print); stock
89+
// builds replace non-ASCII bytes with '?' regardless of UNICODE_SUPPORT,
90+
// which can leave replacement characters (U+FFFD) once decoded.
91+
if (/[^\x20-\x7e]/.test(name)) {
92+
if (!zipinfoUnicode) continue;
93+
const placeholder = name.replace(/[^\x20-\x7e]+/g, '?');
94+
if (zipinfoOut.replace(/[?\uFFFD]+/g, '?').includes(placeholder)) continue;
95+
}
96+
assert.fail(`zipinfo missing ${name}`);
8797
}
8898

8999
const extractDir = path.join(dir, 'out');

0 commit comments

Comments
 (0)