add auto-scheme detection from path. Fix de-tainting in delete_files

This commit is contained in:
Isaac Connor 2018-01-19 11:39:31 -05:00
parent 5472a1a012
commit 9fb1074875
1 changed files with 17 additions and 2 deletions

View File

@ -159,6 +159,20 @@ sub Path {
return $$event{Path};
}
sub Scheme {
my $self = shift;
if ( ! $$self{Scheme} ) {
if ( $$self{RelativePath} ) {
if ( $$self{RelativePath} =~ /^\d+\/\d{4}\-\d{2}\-\d{2}\/\d+$/ ) {
$$self{Scheme} = 'Medium';
} elsif ( $$self{RelativePath} =~ /^\d+\/\d{2}\/\d{2}\/\d{2}\/\d{2}\/\d{2}\/\d{2}\/$/ ) {
$$self{Scheme} = 'Deep';
}
} # end if RelativePath
}
return $$self{Scheme};
}
sub RelativePath {
my $event = shift;
if ( @_ ) {
@ -370,12 +384,13 @@ sub delete_files {
my $event_path = $event->RelativePath();
Debug("Deleting files for Event $$event{Id} from $storage_path/$event_path.");
if ( $event_path ) {
#( $event_path ) = ( $event_path =~ /^(.*)$/ ); # De-taint
( $storage_path ) = ( $storage_path =~ /^(.*)$/ ); # De-taint
( $event_path ) = ( $event_path =~ /^(.*)$/ ); # De-taint
my $command = "/bin/rm -rf $storage_path/$event_path";
ZoneMinder::General::executeShellCommand( $command );
}
if ( $$event{Scheme} eq 'Deep' ) {
if ( $event->Scheme() eq 'Deep' ) {
my $link_path = $event->LinkPath();
Debug("Deleting files for Event $$event{Id} from $storage_path/$link_path.");
if ( $link_path ) {