From 874bd5454dad29284da8979e7cb4b5ac8425110e Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Thu, 12 Nov 2020 10:03:50 +0100 Subject: [PATCH] pxar: fix anchored exclusion at archive root There is no leading slash in an entry's full_path, causing an anchored exclude at the root level to fail, e.g. having "/name" as the content of the file archive/root/.pxarexclude didn't match the file archive/root/name Fix this by prepending a leading slash before matching. Signed-off-by: Fabian Ebner Signed-off-by: Wolfgang Bumiller --- src/pxar/create.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pxar/create.rs b/src/pxar/create.rs index a16005ce..7c8e3edb 100644 --- a/src/pxar/create.rs +++ b/src/pxar/create.rs @@ -443,9 +443,10 @@ impl<'a, 'b> Archiver<'a, 'b> { Err(err) => bail!("stat failed on {:?}: {}", full_path, err), }; + let match_path = PathBuf::from("/").join(full_path.clone()); if self .patterns - .matches(full_path.as_os_str().as_bytes(), Some(stat.st_mode as u32)) + .matches(match_path.as_os_str().as_bytes(), Some(stat.st_mode as u32)) == Some(MatchType::Exclude) { continue;