From b271f7c13cac18cd08192019431c0f62c0b21b7f Mon Sep 17 00:00:00 2001 From: Edgar HIPP Date: Sun, 30 Aug 2015 17:07:07 +0200 Subject: [PATCH] Shouldn't contain \ --- extractor.go | 2 +- pe_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/extractor.go b/extractor.go index a0d43dd..8e80d2c 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 bfcd26a..a2c563a 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 escaped", output) + } + if output[0] != "/usr/bin/env" { + t.Errorf("Doesn't match escaped exactly", output) + } + output = GetAllMatches("!#/usr/bin/env", MatchOptions{}) if len(output) != 1 { t.Errorf("Doesn't match shebang", output) -- 2.44.0