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
This commit is contained in:
Brad King
2026-01-23 08:10:50 -05:00
parent 9ff7341e0f
commit f590010167

View File

@@ -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 {