Added further filename validation

- Now checks for forbidden characters
This commit is contained in:
adroslice 2019-11-21 20:02:29 +01:00
parent 52ddcdddc3
commit 6a17c0a81c

View File

@ -60,7 +60,8 @@ namespace BFR
IsCommitButtonEnabled = IsCommitButtonEnabled =
Files.Any(x => x.Path != x.OldPath) // Check for changes Files.Any(x => x.Path != x.OldPath) // Check for changes
&& Files.GroupBy(x => x.Path).All(g => g.Count() == 1) // Check for duplicates && Files.GroupBy(x => x.Path).All(g => g.Count() == 1) // Check for duplicates
&& !Files.Any(x => x.FullName == ""); // Check for invalid file names; TODO: Further validation && !Files.Any(x => x.FullName == "") // Check for empty file names
&& !Files.Any(x => "?%*:<>|/\\\"".Any(y => x.FullName.Contains(y))); // Check for invalid characters
// Refresh the file list to guarantee that changes are displayed. TODO: Find a better way to do this. // Refresh the file list to guarantee that changes are displayed. TODO: Find a better way to do this.
Files.ReplaceAll(new List<FileModel>(Files)); Files.ReplaceAll(new List<FileModel>(Files));