Recursive archive attachment expansion and filetype/name checks

Julian Field MailScanner at ecs.soton.ac.uk
Tue Apr 25 19:42:16 IST 2006


I have just released 4.53.4 which includes support for .Z and .gz files. 
These are generated by compress and gzip respectively.

Harris S wrote:
> In-Reply-To=4fac50550604241729u16efcb61r4b3773c8778db3e3 at mail.gmail.com
>
> Hello Julian,
>
> Thank you for your prompt reply :-)
>
> However, I think I have nailed it down (although I would appreciate it
> if you told me I did a mistake going into such lengths.... I hope not
> :-S )
>
>
> The MS code does not deal yet with gz (or tgz..) and it does not
> effectively identify the file as an archive (Idea - At the expense of
> compatibility with W32 platforms, could the 'file' system be used to
> identify archives instead of the small $buffer code snippet?)
>
> It turns out that the Archive::Zip module will not expand gz archives
> anyway, so even if the system was able to identify it, it would not be
> able to expand it.
> (Archive::Extract, I did not particularly like it, but what about
> using as a last resort?)
>
> As gzip can only pack one archive at a time, and with the
> proliferation of winZip which does autoexpand gz's (ok... XP native
> zip support is far more dangerous), I thought I should have a go at
> hacking the code.
>
> Below is the result of this morning's effort (and hopefully to a live
> system today) :-)
>
> Regards,
>
> Harris
> -----------------------------------------------
>
> 1747c1747
> <   my($cyclecounter, $rarerror);
> ---
>   
>>   my($cyclecounter, $rarerror, $gziperror);
>>     
> 1906a1907,1908
>   
>>                 # Added by Harris
>>                 $buffer eq "\x1f\x8b\x08\x08" ||
>>     
> 1931c1933,1943
> <       # If unpacking as a zip failed, try it as a rar
> ---
>   
>>       # If unpacking as a zip failed, try it as a gzip
>>
>>       # GZIP unpacking
>>       # Added by Harris
>>
>>       $gziperror = "";
>>       #print STDERR "About to unpack gzip $part\n";
>>       $gziperror = $this->UnpackGzip($part, $explodeinto);
>>       #print STDERR "* * * * * * * UnpackGzip $part returned $ziperror\n";
>>       # If unpacking as a gzip failed, try it as a rar
>>
>>     
> 2400a2413,2430
>   
>> # Unpack a gzip file into the named directory.
>> # Return 1 if an error occurred, else 0.
>> # Return 0 on success.
>> sub UnpackGzip {
>>   my($this, $gzipname, $explodeinto) = @_;
>>
>>   my($gzip);
>>
>>   #print STDERR "Unpacking $gzipname\n";
>>   return 1 if -s "$explodeinto/$gzipname" == 4_237_4; # zip of death?
>>   return 1 unless $gzip = SafePipe( "gunzip -d -S $explodeinto/$gzipname -o gzip_out $gzipname 2>/dev/null", 10);
>>
>>   return 0;
>> }
>>
>>
>>
>>     

-- 
Julian Field
www.MailScanner.info
Buy the MailScanner book at www.MailScanner.info/store
Professional Support Services at www.MailScanner.biz
MailScanner thanks transtec Computers for their support

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.



More information about the MailScanner mailing list