From feed77a850f641cace6cd66a0dcbdd2ee7be71b5 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Fri, 24 Apr 2026 14:59:22 +0300 Subject: [PATCH] Fix filesystem encodings IB-8904 Signed-off-by: Raul Metsma --- cdoc/CDoc.cpp | 4 ++-- cdoc/PKCS11Backend.cpp | 2 +- cdoc/Tar.cpp | 2 +- cdoc/Utils.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cdoc/CDoc.cpp b/cdoc/CDoc.cpp index f86e694e..679ddfc1 100644 --- a/cdoc/CDoc.cpp +++ b/cdoc/CDoc.cpp @@ -86,12 +86,12 @@ getVersion() class ConsoleLogger : public Logger { public: - virtual void logMessage(LogLevel level, std::string_view file, int line, std::string_view message) override + void logMessage(LogLevel level, std::string_view file, int line, std::string_view message) override { // We ignore by default the file name and line number, and call LogMessage with the level and message. std::ostream& ofs = (level == LEVEL_INFO) ? std::cout : std::cerr; if (!file.empty()) { - ofs << std::filesystem::path(file).filename().string() << ':' << line << " " << message << '\n'; + ofs << std::filesystem::path(encodeName(file)).filename().string() << ':' << line << " " << message << '\n'; } else { ofs << message << '\n'; } diff --git a/cdoc/PKCS11Backend.cpp b/cdoc/PKCS11Backend.cpp index 914004c8..f28ff5c3 100644 --- a/cdoc/PKCS11Backend.cpp +++ b/cdoc/PKCS11Backend.cpp @@ -56,7 +56,7 @@ struct libcdoc::PKCS11Backend::Private bool load(const std::string &driver) { #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - return (h = LoadLibraryW(std::filesystem::u8path(driver).c_str())) != 0; + return (h = LoadLibraryW(std::filesystem::path(encodeName(driver)).c_str())) != 0; #else return false; #endif diff --git a/cdoc/Tar.cpp b/cdoc/Tar.cpp index 02077958..5200964f 100644 --- a/cdoc/Tar.cpp +++ b/cdoc/Tar.cpp @@ -231,7 +231,7 @@ libcdoc::TarConsumer::open(const std::string& name, int64_t size) paxData += toPaxRecord("path", name); if(size > 07777777) paxData += toPaxRecord("size", std::to_string(size)); - std::filesystem::path path(name); + std::filesystem::path path(encodeName(name)); if (path.has_parent_path()) { path = path.parent_path() / "PaxHeaders.X" / path.filename(); } else { diff --git a/cdoc/Utils.cpp b/cdoc/Utils.cpp index dff69945..28a023f3 100644 --- a/cdoc/Utils.cpp +++ b/cdoc/Utils.cpp @@ -147,7 +147,7 @@ operator<<(std::ostream& escaped, urlEncode src) continue; } // Keep alphanumeric and other accepted characters intact - if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') { + if (isalnum(uint8_t(c)) || c == '-' || c == '_' || c == '.' || c == '~') { escaped << c; continue; }