extractor.go | 4 ++-- pe_test.go | 10 ++++++++++ validators.go | 2 +- diff --git a/extractor.go b/extractor.go index d42bf0e0032767a5203c4f5ae72383dd0385436f..6a87ab454cc79fb3a2b5daee2ceb52206850e64c 100644 --- a/extractor.go +++ b/extractor.go @@ -3,8 +3,8 @@ import "regexp" func pathExtractor(input string) [][][]byte { - surroundRegex := "[^][ \\t:'\"]" - r := regexp.MustCompile("(" + surroundRegex + "*[\\./]" + surroundRegex + "*)") + surroundRegex := "[^][ \\t:'\"]*" + r := regexp.MustCompile("(" + surroundRegex + "[\\./]" + surroundRegex + ")") temp := [][][]byte{} temp = r.FindAllSubmatch([]byte(input), -1) return temp diff --git a/pe_test.go b/pe_test.go index 58c138fc877e173254de4f87f73afeba02df93a3..844a0e56a69255fb5c2bd59185dc468df7729cde 100644 --- a/pe_test.go +++ b/pe_test.go @@ -73,6 +73,16 @@ if len(output) != 2 { t.Errorf("Doesnt match multi", output) } + output = GetAllMatches("user.test.js") + if len(output) != 1 { + t.Errorf("Doesnt match multiple extensions", output) + } + + output = GetAllMatches("(user.js)") + if len(output) != 1 { + t.Errorf("Doesnt match surrounded by parens", output) + } + output = GetAllMatches("var/") if len(output) != 1 { t.Errorf("Doesnt match dir", output) diff --git a/validators.go b/validators.go index b0501d6839111588ad0bfb4903b597ad41a0c77e..adc811666613f33c9c5c9aae31f6a390f2d66170 100644 --- a/validators.go +++ b/validators.go @@ -67,7 +67,7 @@ return false } func containsInvalidString(input string) bool { - invalidStrings := []string{"(", ")", "and/or", "origin/", "{", "}", "<", ">", "$", "*", "this."} + invalidStrings := []string{"()", "and/or", "origin/", "{", "}", "<", ">", "$", "*", "this."} for _, s := range invalidStrings { if strings.Contains(input, s) { return true