From dec87e1111644e8c18c0ecf5500ac1a8291fe071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 22 Nov 2021 14:01:42 +0000 Subject: [PATCH] make content disposition reflect request base path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- internal/http/services/owncloud/ocdav/get.go | 2 +- internal/http/services/owncloud/ocdav/publicfile.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/http/services/owncloud/ocdav/get.go b/internal/http/services/owncloud/ocdav/get.go index 6bd08c52da..cefc4da7df 100644 --- a/internal/http/services/owncloud/ocdav/get.go +++ b/internal/http/services/owncloud/ocdav/get.go @@ -124,7 +124,7 @@ func (s *svc) handleGet(ctx context.Context, w http.ResponseWriter, r *http.Requ w.Header().Set(HeaderContentType, info.MimeType) w.Header().Set(HeaderContentDisposistion, "attachment; filename*=UTF-8''"+ - path.Base(info.Path)+"; filename=\""+path.Base(info.Path)+"\"") + path.Base(r.RequestURI)+"; filename=\""+path.Base(r.RequestURI)+"\"") w.Header().Set(HeaderETag, info.Etag) w.Header().Set(HeaderOCFileID, wrapResourceID(info.Id)) w.Header().Set(HeaderOCETag, info.Etag) diff --git a/internal/http/services/owncloud/ocdav/publicfile.go b/internal/http/services/owncloud/ocdav/publicfile.go index 2d4ce28595..b369f6650b 100644 --- a/internal/http/services/owncloud/ocdav/publicfile.go +++ b/internal/http/services/owncloud/ocdav/publicfile.go @@ -55,6 +55,7 @@ func (h *PublicFileHandler) Handler(s *svc) http.Handler { return } + r.URL.Path = path.Base(r.URL.Path) switch r.Method { case MethodPropfind: s.handlePropfindOnToken(w, r, h.namespace, false) @@ -120,6 +121,9 @@ func (s *svc) adjustResourcePathInURL(w http.ResponseWriter, r *http.Request) bo return false } + // adjust path in request URL to point at the parent + r.URL.Path = path.Dir(r.URL.Path) + return true }