From abcf2195612d2ce3408816a36330472f4b06ece3 Mon Sep 17 00:00:00 2001 From: Edgar HIPP Date: Sun, 30 Aug 2015 17:07:05 +0200 Subject: [PATCH] Works with shebangs --- extractor.go | 2 +- pe_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/extractor.go b/extractor.go index 19bc274..a0d43dd 100644 --- a/extractor.go +++ b/extractor.go @@ -9,7 +9,7 @@ type MatchOptions struct { } func pathExtractor(input string) [][][]byte { - surroundRegex := "[^]()[ \\t:'\"]*" + surroundRegex := "[^]()!#[ \\t:'\"]*" r := regexp.MustCompile("(" + surroundRegex + "[\\./]" + surroundRegex + ")") temp := [][][]byte{} temp = r.FindAllSubmatch([]byte(input), -1) diff --git a/pe_test.go b/pe_test.go index acb93c1..c88aa0d 100644 --- a/pe_test.go +++ b/pe_test.go @@ -13,6 +13,14 @@ func TestEverything(t *testing.T) { t.Errorf("Matches sentence", output) } + output = GetAllMatches("!#/usr/bin/env", MatchOptions{}) + if len(output) != 1 { + t.Errorf("Doesn't match shebang", output) + } + if output[0] != "/usr/bin/env" { + t.Errorf("Doesn't match shebang", output) + } + output = GetAllMatches("hello .gitignore", MatchOptions{}) if output[0] != ".gitignore" { t.Errorf("Doesnt match hidden files", output) -- 2.44.0