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

@ -58,9 +58,10 @@ namespace BFR
// Validate that there are any changes, and that the new file names are all unique.
IsCommitButtonEnabled =
Files.Any(x => x.Path != x.OldPath) // Check for changes
&& 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.Path != x.OldPath) // Check for changes
&& Files.GroupBy(x => x.Path).All(g => g.Count() == 1) // Check for duplicates
&& !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.
Files.ReplaceAll(new List<FileModel>(Files));