29 lines
798 B
Go
29 lines
798 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 {
|
|
escapedSegment := strings.ReplaceAll(segment, "%", "ZURG25")
|
|
escapedSegment = url.PathEscape(escapedSegment)
|
|
escapedSegment = strings.ReplaceAll(escapedSegment, "ZURG25", "%25")
|
|
segments[i] = escapedSegment
|
|
}
|
|
escapedPath := strings.Join(segments, "/")
|
|
return escapeForXML(escapedPath)
|
|
}
|
|
|
|
func escapeForXML(input string) string {
|
|
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
|
|
}
|