Update shared package

This commit is contained in:
Gabriel20xx committed 2026-11-17 13:35:39 +01:00
1 parent fc01c93aeb
commit 7f21bb9073
2 files changed
+42 -18

No files matched your search

+9 -11
View File
@@ -911,21 +911,19 @@ func urlPath(value string) string {
return value
}
// upstreamMediaPath returns the escaped CarrierNode path for a stored file path. It reports false
// when the stored path is not a safe relative path, or when it contains a query or fragment marker
// that CarrierNode would read as the end of the path.
// upstreamMediaPath returns the CarrierNode path for a stored file path. It reports false only when
// the stored path is not a safe relative path.
//
// url.PathEscape would write a comma as %2C, and the request then keeps that escape as a raw path.
// CarrierNode's router matches a raw path literally, so "Hello, World.mp4" would never be found. A
// URL built from Path alone leaves no raw path, so the name reaches CarrierNode decoded. Query and
// fragment markers are escaped the same way, so they no longer need refusing.
func upstreamMediaPath(filePath string) (string, bool) {
relative := urlPath(filePath)
if !files.SafeRelative(relative) || strings.ContainsAny(relative, "?#") {
if !files.SafeRelative(relative) {
return "", false
}
// Escape each segment so percent-escapes and other reserved characters in a stored name
// reach CarrierNode as literal text, not as an escape or a traversal it decodes later.
segments := strings.Split(relative, "/")
for i, segment := range segments {
segments[i] = url.PathEscape(segment)
}
return strings.Join(segments, "/"), true
return (&url.URL{Path: relative}).EscapedPath(), true
}
// canonicalMediaID returns the numeric media id that identifier spells exactly. Leading zeros, signs