From f590010167d28c003c3e3623b985a00b46726527 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 23 Jan 2026 08:10:50 -0500 Subject: [PATCH] libarchive: Restore tolerance of archives with non-OEM paths on Windows On Windows, since commit 9539a0df9c (LibArchive 2024-09-13, 2024-09-13, v3.31.0-rc1~77^2~3^2) imported libarchive commit `49280bc202a8` (Fix tests on Windows, 2024-03-23, `v3.7.3~17`), libarchive fails to extract archives whose paths are not valid MBS encodings in the host's OEM code page. This broke extraction, e.g., by `cmake -E tar` of archives with UTF-8 paths on Windows. Restore compatibility with CMake 3.30 and below by tolerating encoding conversion errors on Windows. Although affected paths are not extracted correctly, we at least succeed in extracting the rest of such archives. Issue: #26903 --- Utilities/cmlibarchive/libarchive/archive_string.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Utilities/cmlibarchive/libarchive/archive_string.c b/Utilities/cmlibarchive/libarchive/archive_string.c index abf7ad6693..99778bfcbf 100644 --- a/Utilities/cmlibarchive/libarchive/archive_string.c +++ b/Utilities/cmlibarchive/libarchive/archive_string.c @@ -552,7 +552,12 @@ archive_wstring_append_from_mbs_in_codepage(struct archive_wstring *dest, } else mbflag = MB_PRECOMPOSED; + /* FIXME(CMake#26903): Offer control over encoding conversion. + For now, we instead tolerate invalid characters as + libarchive 3.7.2 / CMake 3.30 and below did. */ + #if 0 mbflag |= MB_ERR_INVALID_CHARS; + #endif buffsize = dest->length + length + 1; do {