Fixed file protocol bugs

dev
Ice3man543 2021-03-08 19:20:40 +05:30
parent 1cfc5ce6ef
commit 2717a8b647
4 changed files with 6 additions and 6 deletions

View File

@ -66,20 +66,20 @@ func (r *Request) Compile(options *protocols.ExecuterOptions) error {
if extension == "all" { if extension == "all" {
r.allExtensions = true r.allExtensions = true
} else { } else {
if strings.HasPrefix(extension, ".") { if !strings.HasPrefix(extension, ".") {
extension = "." + extension extension = "." + extension
} }
r.extensions[extension] = struct{}{} r.extensions[extension] = struct{}{}
} }
} }
for _, extension := range defaultDenylist { for _, extension := range defaultDenylist {
if strings.HasPrefix(extension, ".") { if !strings.HasPrefix(extension, ".") {
extension = "." + extension extension = "." + extension
} }
r.extensionDenylist[extension] = struct{}{} r.extensionDenylist[extension] = struct{}{}
} }
for _, extension := range r.ExtensionDenylist { for _, extension := range r.ExtensionDenylist {
if strings.HasPrefix(extension, ".") { if !strings.HasPrefix(extension, ".") {
extension = "." + extension extension = "." + extension
} }
r.extensionDenylist[extension] = struct{}{} r.extensionDenylist[extension] = struct{}{}

View File

@ -16,7 +16,7 @@ func TestFileCompile(t *testing.T) {
ID: templateID, ID: templateID,
MaxSize: 1024, MaxSize: 1024,
NoRecursive: false, NoRecursive: false,
Extensions: []string{"*", ".lock"}, Extensions: []string{"all", ".lock"},
ExtensionDenylist: []string{".go"}, ExtensionDenylist: []string{".go"},
} }
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{ executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{

View File

@ -19,7 +19,7 @@ func TestFindInputPaths(t *testing.T) {
ID: templateID, ID: templateID,
MaxSize: 1024, MaxSize: 1024,
NoRecursive: false, NoRecursive: false,
Extensions: []string{"*", ".lock"}, Extensions: []string{"all", ".lock"},
ExtensionDenylist: []string{".go"}, ExtensionDenylist: []string{".go"},
} }
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{ executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{

View File

@ -23,7 +23,7 @@ func TestFileExecuteWithResults(t *testing.T) {
ID: templateID, ID: templateID,
MaxSize: 1024, MaxSize: 1024,
NoRecursive: false, NoRecursive: false,
Extensions: []string{"*"}, Extensions: []string{"all"},
ExtensionDenylist: []string{".go"}, ExtensionDenylist: []string{".go"},
Operators: operators.Operators{ Operators: operators.Operators{
Matchers: []*matchers.Matcher{{ Matchers: []*matchers.Matcher{{