Files
zurg/pkg/dav/util.go
Ben Sarmiento c8334ecb3b Hotfix
2023-11-27 21:50:00 +01:00

24 lines
804 B
Go

package dav
import (
"net/url"
"strings"
)
func customPathEscape(input string) string {
// First, URL-escape the path segments
segments := strings.Split(input, "/")
for i, segment := range segments {
segments[i] = url.PathEscape(segment)
}
escapedPath := strings.Join(segments, "/")
// Convert any XML-escaped sequences back to URL-escaped sequences
escapedPath = strings.Replace(escapedPath, "&", "%26", -1) // for &
escapedPath = strings.Replace(escapedPath, "<", "%3C", -1) // for <
escapedPath = strings.Replace(escapedPath, ">", "%3E", -1) // for >
escapedPath = strings.Replace(escapedPath, "\"", "%22", -1) // for "
escapedPath = strings.Replace(escapedPath, "'", "%27", -1) // for '
escapedPath = strings.Replace(escapedPath, ":", "%3A", -1) // for :
return escapedPath
}