From: Edgar HIPP Date: Sun, 30 Aug 2015 15:07:07 +0000 (+0200) Subject: Shouldn't contain \ X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=b271f7c13cac18cd08192019431c0f62c0b21b7f;p=path-extractor.git Shouldn't contain \ --- 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)