Browse Source

avoid forbidden chars in path

Michael 2 years ago
parent
commit
485af4b4b5
2 changed files with 5 additions and 2 deletions
  1. 5 1
      client/CPlayerInterface.cpp
  2. 0 1
      lib/vstd/DateUtils.cpp

+ 5 - 1
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 + "/";
 			}
 		}
 

+ 0 - 1
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();
 	}