* extfs/patchfs.in: Allow extraction and deletion of patches

whose filenames start with "../" or "./".
This commit is contained in:
Roland Illig 2004-11-16 23:00:40 +00:00
parent 57708c91cc
commit 48690761d6
2 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2004-11-16 Roland Illig <roland.illig@gmx.de>
* extfs/patchfs.in: Allow extraction and deletion of patches
whose filenames start with "../" or "./".
2004-11-15 Leonard den Ottolander <leonard * den ottolander nl>
* vfs.c: Changed types for mc_chmod, mc_chown, mc_mknod to mode_t,

View File

@ -31,6 +31,12 @@ my $context_contents=qr/^([!+\-\\ \n]|-{3} .* -{4}|\*{3} .* \*{4}|\*{15})/;
my $ls_extract_id=qr/^[^\s]+\s+[^\s]+\s+([^\s]+)\s+([^\s]+)/;
my $basename=qr|^(.*/)*([^/]+)$|;
sub patchfs_canonicalize_path ($) {
my ($fname) = @_;
$fname =~ s,/+,/,g;
$fname =~ s,(^|/)(?:\.?\./)+,$1,;
return $fname;
}
# output unix date in a mc-readable format
sub timef
@ -92,8 +98,9 @@ sub myout
# select diff filename conforming with rules found in diff.info
sub diff_filename
{
my ($fsrc,$fdst)=@_;
my ($fsrc,$fdst)= @_;
$fsrc = patchfs_canonicalize_path ($fsrc);
$fdst = patchfs_canonicalize_path ($fdst);
if (!$fdst && !$fsrc) {
error 'Index: not yet implemented';
} elsif (!$fsrc || $fsrc eq '/dev/null') {
@ -203,6 +210,7 @@ sub copyout
my ($unified,$context)=(0,0);
$file=~s/^(PATCH-(CREATE|REMOVE)\/)?(.*)\.diff$/$3/;
$file = patchfs_canonicalize_path ($file);
# state==1 means diff contents, state==0 mens comments
$state=0; $found=0; $buf='';
@ -223,6 +231,8 @@ sub copyout
$state=1;
($fsrc,$fdst,)=parse_header($unified,$context,\$_);
$fsrc = patchfs_canonicalize_path ($fsrc);
$fdst = patchfs_canonicalize_path ($fdst);
$found=1 if (($fsrc eq $file) || ($fdst eq $file));
} elsif ($state==1 && (($unified && !/$unified_contents/) || ($context && !/$context_contents/))) {