add auto-scheme detection from path. Fix de-tainting in delete_files
This commit is contained in:
parent
5472a1a012
commit
9fb1074875
|
@ -159,6 +159,20 @@ sub Path {
|
||||||
return $$event{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 {
|
sub RelativePath {
|
||||||
my $event = shift;
|
my $event = shift;
|
||||||
if ( @_ ) {
|
if ( @_ ) {
|
||||||
|
@ -370,12 +384,13 @@ sub delete_files {
|
||||||
my $event_path = $event->RelativePath();
|
my $event_path = $event->RelativePath();
|
||||||
Debug("Deleting files for Event $$event{Id} from $storage_path/$event_path.");
|
Debug("Deleting files for Event $$event{Id} from $storage_path/$event_path.");
|
||||||
if ( $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";
|
my $command = "/bin/rm -rf $storage_path/$event_path";
|
||||||
ZoneMinder::General::executeShellCommand( $command );
|
ZoneMinder::General::executeShellCommand( $command );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $$event{Scheme} eq 'Deep' ) {
|
if ( $event->Scheme() eq 'Deep' ) {
|
||||||
my $link_path = $event->LinkPath();
|
my $link_path = $event->LinkPath();
|
||||||
Debug("Deleting files for Event $$event{Id} from $storage_path/$link_path.");
|
Debug("Deleting files for Event $$event{Id} from $storage_path/$link_path.");
|
||||||
if ( $link_path ) {
|
if ( $link_path ) {
|
||||||
|
|
Loading…
Reference in New Issue