fix: convert '\' to '/' on windows (#16852)

This commit is contained in:
Harshavardhana
2023-03-20 00:35:25 -07:00
committed by GitHub
parent 67f4ba154a
commit 8d6558b236

View File

@@ -22,6 +22,7 @@ import (
"net"
"net/http"
"path"
"path/filepath"
"runtime/debug"
"strings"
"sync/atomic"
@@ -349,7 +350,7 @@ func hasBadHost(host string) error {
// Check if the incoming path has bad path components,
// such as ".." and "."
func hasBadPathComponent(path string) bool {
path = strings.TrimSpace(path)
path = filepath.ToSlash(strings.TrimSpace(path)) // For windows '\' must be converted to '/'
for _, p := range strings.Split(path, SlashSeparator) {
switch strings.TrimSpace(p) {
case dotdotComponent: