Skip to content
Permalink
Browse files

Fix local saves with "." having their name cut off, add a warning for…

… a few invalid file names
  • Loading branch information...
jacob1 committed Feb 20, 2019
1 parent 16d686e commit 646935edb37b71225434ce78347f2536945a8ba9
Showing with 6 additions and 2 deletions.
  1. +1 −1 src/gui/filebrowser/FileBrowserActivity.cpp
  2. +5 −1 src/gui/save/LocalSaveActivity.cpp
@@ -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)
@@ -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());

0 comments on commit 646935e

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.