mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-29 07:58:55 -06:00
fix thumbnails for empty trailing paths
This commit is contained in:
5
changelog/unreleased/share-jail-fixes.md
Normal file
5
changelog/unreleased/share-jail-fixes.md
Normal file
@@ -0,0 +1,5 @@
|
||||
Bugfix: Fix Thumbnails for IDs without a trailing path
|
||||
|
||||
The routes in the chi router were not matching thumbnail requests without a trailing path.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/3791
|
||||
@@ -1,7 +1,6 @@
|
||||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -43,9 +42,6 @@ func ParseThumbnailRequest(r *http.Request) (*ThumbnailRequest, error) {
|
||||
ctx := r.Context()
|
||||
|
||||
fp := ctx.Value(constants.ContextKeyPath).(string)
|
||||
if fp == "" {
|
||||
return nil, errors.New("invalid file path")
|
||||
}
|
||||
|
||||
id := ""
|
||||
v := ctx.Value(constants.ContextKeyID)
|
||||
|
||||
@@ -79,10 +79,14 @@ func NewService(opts ...Option) (Service, error) {
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(svc.DavUserContext())
|
||||
|
||||
r.Get("/remote.php/dav/spaces/{id}", svc.SpacesThumbnail)
|
||||
r.Get("/remote.php/dav/spaces/{id}/*", svc.SpacesThumbnail)
|
||||
r.Get("/dav/spaces/{id}", svc.SpacesThumbnail)
|
||||
r.Get("/dav/spaces/{id}/*", svc.SpacesThumbnail)
|
||||
|
||||
r.Get("/remote.php/dav/files/{id}", svc.Thumbnail)
|
||||
r.Get("/remote.php/dav/files/{id}/*", svc.Thumbnail)
|
||||
r.Get("/dav/files/{id}", svc.Thumbnail)
|
||||
r.Get("/dav/files/{id}/*", svc.Thumbnail)
|
||||
})
|
||||
|
||||
@@ -151,11 +155,12 @@ func (g Webdav) DavUserContext() func(next http.Handler) http.Handler {
|
||||
}
|
||||
|
||||
if id != "" {
|
||||
filePath = strings.TrimPrefix(filePath, path.Join("/remote.php/dav/spaces", id)+"/")
|
||||
filePath = strings.TrimPrefix(filePath, path.Join("/dav/spaces", id)+"/")
|
||||
filePath = strings.TrimPrefix(filePath, path.Join("/remote.php/dav/spaces", id))
|
||||
filePath = strings.TrimPrefix(filePath, path.Join("/dav/spaces", id))
|
||||
|
||||
filePath = strings.TrimPrefix(filePath, path.Join("/remote.php/dav/files", id)+"/")
|
||||
filePath = strings.TrimPrefix(filePath, path.Join("/dav/files", id)+"/")
|
||||
filePath = strings.TrimPrefix(filePath, path.Join("/remote.php/dav/files", id))
|
||||
filePath = strings.TrimPrefix(filePath, path.Join("/dav/files", id))
|
||||
filePath = strings.TrimPrefix(filePath, "/")
|
||||
}
|
||||
|
||||
ctx = context.WithValue(ctx, constants.ContextKeyPath, filePath)
|
||||
|
||||
Reference in New Issue
Block a user