Skip to content

Commit

Permalink
Remove illegal char check for project creation
Browse files Browse the repository at this point in the history
  • Loading branch information
EngincanV committed May 17, 2021
1 parent 05522af commit ed07b3c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,11 @@ public static class ProjectNameValidator
"LPT2"
};

private static readonly char[] IllegalChars = new[]
{
'/',
'?',
':',
'&',
'\\',
'*',
'\'',
'<',
'>',
'|',
'#',
'%',
};

private static bool HasParentDirectoryString(string projectName)
{
return projectName.Contains("..");
}

private static bool HasIllegalChar(string projectName)
{
foreach (var illegalChar in IllegalChars)
{
if (projectName.Contains(illegalChar))
{
return true;
}
}

return false;
}

private static bool HasSurrogateOrControlChar(string projectName)
{
return projectName.Any(chr => char.IsControl(chr) || char.IsSurrogate(chr));
Expand All @@ -76,11 +47,6 @@ public static bool IsValid(string projectName)
throw new CliUsageException("Project name cannot be empty!");
}

if (HasIllegalChar(projectName))
{
return false;
}

if (HasSurrogateOrControlChar(projectName))
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,6 @@ public async Task IllegalProjectName_Test()
}
}

[Fact]
public async Task ContainsIllegalChar_Test()
{
var illegalChars = new[]
{
'/',
'?',
':',
'&',
'\\',
'*',
'\'',
'<',
'>',
'|',
'#',
'%',
};

foreach (var illegalChar in illegalChars)
{
var args = new CommandLineArgs("new", "Test" + illegalChar);
await _newCommand.ExecuteAsync(args).ShouldThrowAsync<CliUsageException>();
}
}

[Fact]
public async Task ParentDirectoryContain_Test()
{
Expand Down

0 comments on commit ed07b3c

Please sign in to comment.