Fix local saves with "." having their name cut off, add a warning for a few invalid file names

This commit is contained in:
jacob1 2019-02-19 23:24:39 -05:00
parent 16d686e949
commit 646935edb3
2 changed files with 6 additions and 2 deletions

View File

@ -69,7 +69,7 @@ class LoadFilesTask: public Task
saveFiles.push_back(saveFile);
ByteString filename = (*iter).SplitFromEndBy(PATH_SEP).After();
filename = filename.SplitBy('.').Before();
filename = filename.SplitFromEndBy('.').Before();
saveFile->SetDisplayName(filename.FromUtf8());
}
catch(std::exception & e)

View File

@ -90,7 +90,11 @@ void LocalSaveActivity::Save()
virtual ~FileOverwriteConfirmation() { }
};
if(filenameField->GetText().length())
if (filenameField->GetText().Contains('/') || filenameField->GetText().BeginsWith("."))
{
new ErrorMessage("Error", "Invalid filename.");
}
else if (filenameField->GetText().length())
{
ByteString finalFilename = ByteString(LOCAL_SAVE_DIR) + ByteString(PATH_SEP) + filenameField->GetText().ToUtf8() + ".cps";
save.SetDisplayName(filenameField->GetText());