From 2aa2c9af972724efb9b7e8de765bab48182c0d9e Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Sat, 28 Jun 2025 10:10:06 +0200 Subject: [PATCH] ctest: Don't modify build and site names CTest currently removes non-filename characters from CTEST_SITE and CTEST_BUILDNAME in an inconsistent way, which leads to unconnected information on CDash. Non-filename characters actually don't cause any issue in CDash at all, nor are they invalid XML. The only place where removing them may be needed is when an actual filename is constructed. Remove the filtering from the SafeBuildIdField function and place it where a filename is constructed. --- Source/CTest/cmCTestSubmitHandler.cxx | 7 +++++++ Source/cmCTest.cxx | 27 +-------------------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 200ba038c2..49b71b6b8c 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -9,8 +9,10 @@ #include #include +#include #include #include +#include #include #include @@ -226,6 +228,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( std::string remote_file = remoteprefix + cmSystemTools::GetFilenameName(file); + // Erase non-filename and non-space whitespace characters. + cm::erase_if(remote_file, [](char c) { + return cm::contains("\\:*?\"<>|\n\r\t\f\v"_s, c); + }); + *this->LogFile << "\tUpload file: " << local_file << " to " << remote_file << std::endl; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f6c05360c8..c1e586bdf0 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1005,32 +1005,7 @@ bool cmCTest::RunMakeCommand(std::string const& command, std::string& output, std::string cmCTest::SafeBuildIdField(std::string const& value) { - std::string safevalue(value); - - if (!safevalue.empty()) { - // Disallow non-filename and non-space whitespace characters. - // If they occur, replace them with "" - // - char const* disallowed = "\\:*?\"<>|\n\r\t\f\v"; - - if (safevalue.find_first_of(disallowed) != std::string::npos) { - std::string::size_type i = 0; - std::string::size_type n = strlen(disallowed); - char replace[2]; - replace[1] = 0; - - for (i = 0; i < n; ++i) { - replace[0] = disallowed[i]; - cmSystemTools::ReplaceString(safevalue, replace, ""); - } - } - } - - if (safevalue.empty()) { - safevalue = "(empty)"; - } - - return safevalue; + return value.empty() ? "(empty)" : value; } void cmCTest::StartXML(cmXMLWriter& xml, cmake* cm, bool append)