Skip to content

Commit

Permalink
Improve path sanitization.
Browse files Browse the repository at this point in the history
  • Loading branch information
thmull committed Aug 29, 2023
1 parent ddb388d commit 60f32eb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions helpers/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,19 @@ func SettingsPaths() ([]string, fs.FS, error) {
}

// we set the main root from the path root
mainRoot = root + "/"
mainRoot = root

// we replace the slashes
value = filepath.ToSlash(value)

// we remove the volume or root part (e.g. 'c:/' on Windows or '/' on Linux)
value = value[len(root)+1:]
sanitizedValues = append(sanitizedValues, value)
}

// on Linux, mainRoot will be unset
if mainRoot == "" {
mainRoot = "/"
// we append the value to the sanitized paths
sanitizedValues = append(sanitizedValues, value)
}

return sanitizedValues, os.DirFS(mainRoot), nil
return sanitizedValues, os.DirFS(mainRoot + "/"), nil
}

func Settings(settingsPaths []string, fS fs.FS) (kodex.Settings, error) {
Expand Down

0 comments on commit 60f32eb

Please sign in to comment.