1
0
mirror of https://github.com/drakkan/sftpgo.git synced 2025-11-29 22:08:10 +02:00

windows: try to escape trailing double quote in user input

we try to remove the trailing double quote for user input such as this one

sftpgo.exe serve -c "C:\ProgramData\SFTPGO\"

the value for the -c flag is parsed as:

C:\ProgramData\SFTPGO"

this is what the user specified, but the user want this value:

C:\ProgramData\SFTPGO

so we try to remove the trailing double quote.

Please note that we cannot do anything for something like this:

-c "C:\ProgramData\SFTPGO\" -l "sftpgo.log"

in this case the -l flag will be ignored and the value for the c flag is:

C:\ProgramData\SFTPGO" -l sftpgo.log

and so probably it is invalid. This is definitely a bad user input
This commit is contained in:
Nicola Murino
2020-03-04 09:27:14 +01:00
parent f9fc5792fd
commit 31d285813e
8 changed files with 29 additions and 18 deletions

View File

@@ -4,7 +4,6 @@ package cmd
import (
"fmt"
"os"
"path/filepath"
"strconv"
"github.com/drakkan/sftpgo/config"
@@ -141,7 +140,7 @@ func addServeFlags(cmd *cobra.Command) {
func getCustomServeFlags() []string {
result := []string{}
if configDir != defaultConfigDir {
configDir = filepath.Clean(configDir)
configDir = utils.CleanDirInput(configDir)
result = append(result, "--"+configDirFlag)
result = append(result, configDir)
}
@@ -149,10 +148,7 @@ func getCustomServeFlags() []string {
result = append(result, "--"+configFileFlag)
result = append(result, configFile)
}
if logFilePath != defaultLogFile && utils.IsFileInputValid(logFilePath) {
if !filepath.IsAbs(logFilePath) {
logFilePath = filepath.Join(configDir, logFilePath)
}
if logFilePath != defaultLogFile {
result = append(result, "--"+logFilePathFlag)
result = append(result, logFilePath)
}