mistake should of been \ not / to escape -

This commit is contained in:
David Lebee 2020-08-20 19:44:08 -04:00
parent 8314145b44
commit 21cb1d11bf
2 changed files with 9 additions and 2 deletions

View File

@ -227,7 +227,7 @@ namespace PoweredSoft.Storage.S3
public string SanitizeFileName(string key, string replacement)
{
string pattern = @"[^a-zA-Z0-9.!/-_*'()]";
string pattern = @"[^a-zA-Z0-9.!\-_*'()]";
string substitution = replacement;
string input = key;
RegexOptions options = RegexOptions.Multiline;
@ -240,7 +240,7 @@ namespace PoweredSoft.Storage.S3
public bool IsFileNameAllowed(string fileName)
{
string pattern = @"[^a-zA-Z0-9.!/-_*'()]";
string pattern = @"[^a-zA-Z0-9.!\-_*'()]";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
var hasMatches = regex.IsMatch(fileName);

View File

@ -15,6 +15,13 @@ namespace PoweredSoft.Storage.Test
Assert.IsFalse(space.IsFileNameAllowed("Operations$$.pdf"), "Should not be valid");
}
[TestMethod]
public void CanContainDash()
{
var space = GetMockS3Space();
Assert.IsTrue(space.IsFileNameAllowed("Operations-yay.pdf"), "Should be allowed");
}
[TestMethod]
public void NameSanitation()
{