From: Eric Wong Date: Thu, 1 May 2014 20:38:39 +0000 (+0000) Subject: extractor: filter out non-message paths X-Git-Tag: v0.1.0~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2b6afb5111be5de36f2438cdd6aeac88e829f236;p=ssoma-mda.git extractor: filter out non-message paths We may allow files like "README" to appear in ssoma repositories to reduce confusion. --- 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 }