From b4a35feddbf8b83fd966e59f56b7ea3ea8e5dc4a Mon Sep 17 00:00:00 2001 From: Alex Aperis Date: Tue, 18 Apr 2023 20:23:40 +0200 Subject: [PATCH] fix backslash to slash substitution --- helper/helper.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helper/helper.go b/helper/helper.go index bf3cc1d..2c2ad5f 100644 --- a/helper/helper.go +++ b/helper/helper.go @@ -372,13 +372,13 @@ func TLScertToFile(filename string, derBytes []byte) error { func FormatUploadFilePath(filePath string) (string, error) { // Check for mixed "\" and "/" in filepath. Stop and throw an error if true so that - // we do not end up with unintended folder structure when applying ToSlash later on + // we do not end up with unintended folder structure when applying ReplaceAll below if strings.Contains(filePath, "\\") && strings.Contains(filePath, "/") { return filePath, fmt.Errorf("filepath contains mixed '\\' and '/' characters") } - // make path separators os compatible - outPath := filepath.ToSlash(filePath) + // make any windows path separators linux compatible + outPath := strings.ReplaceAll(filePath, "\\", "/") // [\x00-\x1F\x7F] is the control character set re := regexp.MustCompile(`[\\:\*\?"<>\|\x00-\x1F\x7F]`)