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 { escapedSegment := strings.ReplaceAll(segment, "%", "ZURG25") escapedSegment = url.PathEscape(escapedSegment) escapedSegment = strings.ReplaceAll(escapedSegment, "ZURG25", "%25") segments[i] = escapedSegment } escapedPath := strings.Join(segments, "/") // Convert any XML-escaped sequences back to URL-escaped sequences escapedPath = strings.ReplaceAll(escapedPath, "$", "%24") escapedPath = strings.ReplaceAll(escapedPath, "&", "%26") escapedPath = strings.ReplaceAll(escapedPath, "+", "%2B") escapedPath = strings.ReplaceAll(escapedPath, ":", "%3A") escapedPath = strings.ReplaceAll(escapedPath, "@", "%40") return escapedPath } func customPathEscape2(input string) string { // Convert any XML-escaped sequences back to URL-escaped sequences input = strings.ReplaceAll(input, "$", "%24") input = strings.ReplaceAll(input, "&", "%26") input = strings.ReplaceAll(input, "+", "%2B") input = strings.ReplaceAll(input, ":", "%3A") input = strings.ReplaceAll(input, "@", "%40") return input }