fix non-anchored literal matches starting with a slash

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-05-29 11:05:13 +02:00
parent 1c51800f17
commit 1d6ca6ca1b

View File

@ -252,12 +252,8 @@ impl MatchEntry {
}
}
if path[0] != b'/' {
// we had "foo/bar", so we haven't yet tried to match the whole string:
self.matches_path_exact(path)
} else {
false
}
// and try the whole string as well:
self.matches_path_exact(path)
}
/// Test whether this entry's pattern matches a path exactly.
@ -453,3 +449,11 @@ fn test_anchored_matches() {
);
assert_eq!(matchlist.matches("another/some/path", None), None);
}
#[test]
fn test_literal_matches() {
let matchlist = vec![
MatchEntry::new(MatchPattern::Literal(b"/bin/mv".to_vec()), MatchType::Include),
];
assert_eq!(matchlist.matches("/bin/mv", None), Some(MatchType::Include));
}