Skip to content

Commit fa7edcc

Browse files
Fixup deletePath. Handle links, and report failures. Fix escaping the filename and put it in quotes in case it has spaces. Fixes #4446
1 parent 4986681 commit fa7edcc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

web/includes/functions.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,16 @@ function getEventDefaultVideoPath($event) {
369369

370370
function deletePath( $path ) {
371371
ZM\Debug('Deleting '.$path);
372-
if ( is_dir($path) ) {
373-
system(escapeshellcmd('rm -rf '.$path));
374-
} else if ( file_exists($path) ) {
375-
unlink($path);
372+
if (is_link($path)) {
373+
if (!unlink($path)) ZM\Debug("Failed to unlink $path");
374+
} else if (is_dir($path)) {
375+
if (false === ($output = system('rm -rf "'.escapeshellcmd($path).'"'))) {
376+
ZM\Warning('Failed doing rm -rf "'.escapeshellcmd($path).'"');
377+
}
378+
} else if (file_exists($path)) {
379+
if (!unlink($path)) ZM\Debug("Failed to delete $path");
380+
} else {
381+
ZM\Warning("Path $path does not exist in deletePath()");
376382
}
377383
}
378384

0 commit comments

Comments
 (0)