mistake should of been \ not / to escape -
This commit is contained in:
parent
8314145b44
commit
21cb1d11bf
@ -227,7 +227,7 @@ namespace PoweredSoft.Storage.S3
|
|||||||
|
|
||||||
public string SanitizeFileName(string key, string replacement)
|
public string SanitizeFileName(string key, string replacement)
|
||||||
{
|
{
|
||||||
string pattern = @"[^a-zA-Z0-9.!/-_*'()]";
|
string pattern = @"[^a-zA-Z0-9.!\-_*'()]";
|
||||||
string substitution = replacement;
|
string substitution = replacement;
|
||||||
string input = key;
|
string input = key;
|
||||||
RegexOptions options = RegexOptions.Multiline;
|
RegexOptions options = RegexOptions.Multiline;
|
||||||
@ -240,7 +240,7 @@ namespace PoweredSoft.Storage.S3
|
|||||||
|
|
||||||
public bool IsFileNameAllowed(string fileName)
|
public bool IsFileNameAllowed(string fileName)
|
||||||
{
|
{
|
||||||
string pattern = @"[^a-zA-Z0-9.!/-_*'()]";
|
string pattern = @"[^a-zA-Z0-9.!\-_*'()]";
|
||||||
RegexOptions options = RegexOptions.Multiline;
|
RegexOptions options = RegexOptions.Multiline;
|
||||||
Regex regex = new Regex(pattern, options);
|
Regex regex = new Regex(pattern, options);
|
||||||
var hasMatches = regex.IsMatch(fileName);
|
var hasMatches = regex.IsMatch(fileName);
|
||||||
|
@ -15,6 +15,13 @@ namespace PoweredSoft.Storage.Test
|
|||||||
Assert.IsFalse(space.IsFileNameAllowed("Operations$$.pdf"), "Should not be valid");
|
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]
|
[TestMethod]
|
||||||
public void NameSanitation()
|
public void NameSanitation()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user