From bc9625fece93068d85ab357d541a09471f01153a Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Thu, 23 Jun 2022 16:36:56 -0600 Subject: [PATCH] Disallow illegal chars in templates --- Source/LibationFileManager/Templates.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/LibationFileManager/Templates.cs b/Source/LibationFileManager/Templates.cs index 7a856c73..f9a4d06f 100644 --- a/Source/LibationFileManager/Templates.cs +++ b/Source/LibationFileManager/Templates.cs @@ -54,10 +54,7 @@ namespace LibationFileManager if (template is null) return new[] { ERROR_NULL_IS_INVALID }; - if (template.Contains(':') - || template.Contains(Path.DirectorySeparatorChar) - || template.Contains(Path.AltDirectorySeparatorChar) - ) + if (ReplacementCharacters.ContainsInvalid(template.Replace("<","").Replace(">",""))) return new[] { ERROR_INVALID_FILE_NAME_CHAR }; return Valid; @@ -200,6 +197,10 @@ namespace LibationFileManager if (template.Contains(':')) return new[] { ERROR_FULL_PATH_IS_INVALID }; + // must be relative. no colons. all other path chars are valid enough to pass this check and will be handled on final save. + if (ReplacementCharacters.ContainsInvalid(template.Replace("<", "").Replace(">", ""))) + return new[] { ERROR_INVALID_FILE_NAME_CHAR }; + return Valid; }