mirror of
https://git.proxmox.com/git/pathpatterns
synced 2025-07-16 11:52:34 +00:00
fix non-anchored literal matches starting with a slash
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
1c51800f17
commit
1d6ca6ca1b
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user