Skip to content

Commit

Permalink
make content disposition reflect request base path
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Nov 22, 2021
1 parent 29826a3 commit dec87e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions internal/http/services/owncloud/ocdav/publicfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit dec87e1

Please sign in to comment.