mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
tar: Use UTF-8 as a default encoding
Use UTF-8 by default, as this has become common for cross-platform
archive distribution, and our previous default was platform-specific.
Also revert commit f590010167 (libarchive: Restore tolerance of archives
with non-OEM paths on Windows, 2026-01-23, v3.31.11~1^2). Its primary
purpose was to tolerate UTF-8 paths when extracting archives, which we
now handle by default.
Issue: #26903
This commit is contained in:
committed by
Brad King
parent
21eb53e9eb
commit
0c355dfcf7
@@ -224,8 +224,11 @@ CPack generators which are essentially archives at their core. These include:
|
||||
|
||||
Specify the pathname character encoding used in package archives.
|
||||
|
||||
:Default: ``OEM``
|
||||
:Default: ``UTF-8``
|
||||
|
||||
See the :option:`cmake -E tar <cmake-E tar>` tool's
|
||||
:option:`--cmake-tar-encoding <cmake-E_tar --cmake-tar-encoding>` flag
|
||||
for supported encoding names.
|
||||
|
||||
In CMake 4.3 and below, the ``OEM`` encoding (current locale)
|
||||
was always used.
|
||||
|
||||
@@ -1705,12 +1705,15 @@ Available commands are:
|
||||
``UTF-8``
|
||||
Archive pathnames are encoded as UTF-8.
|
||||
|
||||
This is the default since CMake 4.4.
|
||||
|
||||
``OEM``
|
||||
On Windows platforms, pathnames are encoded as using the original
|
||||
equipment manufacturer (OEM) code page. On non-Windows platforms,
|
||||
pathnames are encoded according to the current locale.
|
||||
|
||||
This is the default value.
|
||||
In CMake 4.3 and below, the ``OEM`` encoding (current locale)
|
||||
was always used.
|
||||
|
||||
``UTF-16LE``, ``UTF-16BE``
|
||||
Archive pathnames are encoded as UTF-16 little-endian or big-endian.
|
||||
|
||||
@@ -614,7 +614,7 @@ int cmCPackArchiveGenerator::GetCompressionLevel() const
|
||||
|
||||
std::string cmCPackArchiveGenerator::GetEncoding() const
|
||||
{
|
||||
std::string encoding = "OEM";
|
||||
std::string encoding = "UTF-8";
|
||||
|
||||
if (cmValue v = this->GetOptionIfSet("CPACK_ARCHIVE_ENCODING")) {
|
||||
encoding = *v;
|
||||
|
||||
@@ -213,7 +213,7 @@ bool DebGenerator::generateDataTar() const
|
||||
}
|
||||
cmArchiveWrite data_tar(
|
||||
fileStream_data_tar, this->TarCompressionType, this->DebianArchiveType,
|
||||
"OEM", this->CompressionLevel, static_cast<int>(this->NumThreads));
|
||||
"UTF-8", this->CompressionLevel, static_cast<int>(this->NumThreads));
|
||||
if (!data_tar.Open()) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"Error opening the archive \""
|
||||
@@ -344,7 +344,7 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const
|
||||
return false;
|
||||
}
|
||||
cmArchiveWrite control_tar(fileStream_control_tar, this->TarCompressionType,
|
||||
this->DebianArchiveType, "OEM",
|
||||
this->DebianArchiveType, "UTF-8",
|
||||
this->CompressionLevel);
|
||||
if (!control_tar.Open()) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
|
||||
@@ -56,8 +56,8 @@ public:
|
||||
/** Construct with output stream to which to write archive. */
|
||||
cmArchiveWrite(std::ostream& os, Compress c = CompressNone,
|
||||
std::string const& format = "paxr",
|
||||
std::string const& encoding = "OEM", int compressionLevel = 0,
|
||||
int numThreads = 1);
|
||||
std::string const& encoding = "UTF-8",
|
||||
int compressionLevel = 0, int numThreads = 1);
|
||||
|
||||
~cmArchiveWrite();
|
||||
|
||||
|
||||
+1
-1
@@ -1252,7 +1252,7 @@ std::string cmCTest::Base64GzipEncodeFile(std::string const& file)
|
||||
files.push_back(file);
|
||||
|
||||
if (!cmSystemTools::CreateTar(
|
||||
tarFile, files, {}, cmSystemTools::TarCompressGZip, "OEM", false)) {
|
||||
tarFile, files, {}, cmSystemTools::TarCompressGZip, "UTF-8", false)) {
|
||||
cmCTestLog(this, ERROR_MESSAGE,
|
||||
"Error creating tar while "
|
||||
"encoding file: "
|
||||
|
||||
+1
-1
@@ -1920,7 +1920,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
||||
cmSystemTools::TarCompressAuto;
|
||||
int nCompress = 0;
|
||||
bool doing_options = true;
|
||||
std::string encoding = "OEM";
|
||||
std::string encoding = "UTF-8";
|
||||
for (auto const& arg : cmMakeRange(args).advance(4)) {
|
||||
if (doing_options && cmHasLiteralPrefix(arg, "--")) {
|
||||
if (arg == "--") {
|
||||
|
||||
@@ -87,7 +87,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
||||
|
||||
// Extract without verbose, with timestamps
|
||||
bool result1 = cmSystemTools::ExtractTar(
|
||||
archiveFile, files, cmSystemTools::cmTarExtractTimestamps::Yes, "OEM",
|
||||
archiveFile, files, cmSystemTools::cmTarExtractTimestamps::Yes, "UTF-8",
|
||||
false);
|
||||
(void)result1;
|
||||
|
||||
@@ -103,7 +103,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
||||
// Extract with verbose, without timestamps
|
||||
files.clear();
|
||||
bool result2 = cmSystemTools::ExtractTar(
|
||||
archiveFile, files, cmSystemTools::cmTarExtractTimestamps::No, "OEM",
|
||||
archiveFile, files, cmSystemTools::cmTarExtractTimestamps::No, "UTF-8",
|
||||
true);
|
||||
(void)result2;
|
||||
|
||||
|
||||
@@ -575,12 +575,7 @@ 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 {
|
||||
|
||||
Reference in New Issue
Block a user