Skip to content
Snippets Groups Projects
Unverified Commit 4a818166 authored by Martyn Gigg's avatar Martyn Gigg Committed by GitHub
Browse files

Merge pull request #22783 from mantidproject/22780_proj_recovery_sanitise_chars

Project Recovery - Sanitise filename characters
parents c67257e9 edec2fd2
No related merge requests found
......@@ -11,7 +11,9 @@
#include "MantidKernel/Logger.h"
#include "MantidKernel/UsageService.h"
#include "boost/algorithm/string/classification.hpp"
#include "boost/optional.hpp"
#include "boost/range/algorithm_ext/erase.hpp"
#include "Poco/DirectoryIterator.h"
#include "Poco/NObserver.h"
......@@ -132,6 +134,13 @@ getRecoveryFolderCheckpoints(const std::string &recoveryFolderPath) {
return folderPaths;
}
std::string removeInvalidFilenameChars(std::string s) {
// NTFS is most restrictive, so blacklist on this
std::string blacklistChars{":*?<>|/\"\\"};
boost::remove_erase_if(s, boost::is_any_of(blacklistChars));
return s;
}
const std::string OUTPUT_PROJ_NAME = "recovery.mantid";
// Config keys
......@@ -437,7 +446,7 @@ void ProjectRecovery::saveWsHistories(const Poco::Path &historyDestFolder) {
alg->setLogging(false);
for (const auto &ws : wsHandles) {
std::string filename = ws->getName();
std::string filename = removeInvalidFilenameChars(ws->getName());
filename.append(".py");
Poco::Path destFilename = historyDestFolder;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment