#42 Allow deletion of ./*
This commit is contained in:

committed by
Sebastian Serth

parent
59ca63268b
commit
eecacc08bf
@ -253,11 +253,15 @@ func fileDeletionCommand(pathsToDelete []dto.FilePath) string {
|
|||||||
}
|
}
|
||||||
command := "rm --recursive --force "
|
command := "rm --recursive --force "
|
||||||
for _, filePath := range pathsToDelete {
|
for _, filePath := range pathsToDelete {
|
||||||
// To avoid command injection, filenames need to be quoted.
|
if filePath == "./*" {
|
||||||
// See https://unix.stackexchange.com/questions/347332/what-characters-need-to-be-escaped-in-files-without-quotes
|
command += "./* "
|
||||||
// for details.
|
} else {
|
||||||
singleQuoteEscapedFileName := strings.ReplaceAll(filePath.Cleaned(), "'", "'\\''")
|
// To avoid command injection, filenames need to be quoted.
|
||||||
command += fmt.Sprintf("'%s' ", singleQuoteEscapedFileName)
|
// See https://unix.stackexchange.com/questions/347332/what-characters-need-to-be-escaped-in-files-without-quotes
|
||||||
|
// for details.
|
||||||
|
singleQuoteEscapedFileName := strings.ReplaceAll(filePath.Cleaned(), "'", "'\\''")
|
||||||
|
command += fmt.Sprintf("'%s' ", singleQuoteEscapedFileName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
command += ";"
|
command += ";"
|
||||||
return command
|
return command
|
||||||
|
Reference in New Issue
Block a user