From 485af4b4b54b7f8d47bb5774736e1a0c938e2103 Mon Sep 17 00:00:00 2001 From: Michael <13953785+Laserlicht@users.noreply.github.com> Date: Wed, 23 Aug 2023 22:23:05 +0200 Subject: [PATCH] avoid forbidden chars in path --- client/CPlayerInterface.cpp | 6 +++++- lib/vstd/DateUtils.cpp | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index ea72d001c..f365d1cea 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -212,7 +212,11 @@ void CPlayerInterface::performAutosave() prefix = settings["general"]["savePrefix"].String(); if(prefix.empty()) { - prefix = cb->getMapHeader()->name.substr(0, 15) + "_" + cb->getStartInfo()->startTimeIso8601 + "/"; + std::string name = cb->getMapHeader()->name.substr(0, 15); + std::string forbiddenChars("\\/:?\"<>| "); + std::replace_if(name.begin(), name.end(), [&](char c) { return std::string::npos != forbiddenChars.find(c); }, '_' ); + + prefix = name + "_" + cb->getStartInfo()->startTimeIso8601 + "/"; } } diff --git a/lib/vstd/DateUtils.cpp b/lib/vstd/DateUtils.cpp index f494f3e66..8965ae72f 100644 --- a/lib/vstd/DateUtils.cpp +++ b/lib/vstd/DateUtils.cpp @@ -19,7 +19,6 @@ namespace vstd { std::tm tm = *std::localtime(&dt); std::stringstream s; - s.imbue(std::locale("")); s << std::put_time(&tm, "%Y%m%dT%H%M%S"); return s.str(); }