From 2b6afb5111be5de36f2438cdd6aeac88e829f236 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 1 May 2014 20:38:39 +0000 Subject: [PATCH] extractor: filter out non-message paths We may allow files like "README" to appear in ssoma repositories to reduce confusion. --- lib/Ssoma/Extractor.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Ssoma/Extractor.pm b/lib/Ssoma/Extractor.pm index 11ad130..9d7bcce 100644 --- a/lib/Ssoma/Extractor.pm +++ b/lib/Ssoma/Extractor.pm @@ -13,14 +13,17 @@ sub new { bless { git => $git, ref => "refs/heads/master" }, $class; } -# runs a command which returns a list of files, no file name sanitization -# here needed since all of the path names stored in git trees are controlled -# by us (and based on SHA-1 hexdigest) +# runs a command which returns a list of files belonging to emails +# This won't prevent invalid/corrupt messages from attempts at +# being imported, though. This allows administrators to add things +# like a top-level README file to avoid confusing folks who may +# accidentally check out the ssoma repository as a working copy. sub _flist { my ($cmd) = @_; my @rv = `$cmd`; $? == 0 or die "$cmd failed: $?\n"; chomp @rv; + @rv = grep(m!\A[a-f0-9]{2}/[a-f0-9]{38}(?:/[a-f0-9]{40})?\z!, @rv); \@rv } -- 2.26.2