fix thumbnails for empty trailing paths
This commit is contained in:
3 files changed
+14
-8
No files matched your search
@@ -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
|
package requests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -43,9 +42,6 @@ func ParseThumbnailRequest(r *http.Request) (*ThumbnailRequest, error) {
|
|||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
|
|
||||||
fp := ctx.Value(constants.ContextKeyPath).(string)
|
fp := ctx.Value(constants.ContextKeyPath).(string)
|
||||||
if fp == "" {
|
|
||||||
return nil, errors.New("invalid file path")
|
|
||||||
}
|
|
||||||
|
|
||||||
id := ""
|
id := ""
|
||||||
v := ctx.Value(constants.ContextKeyID)
|
v := ctx.Value(constants.ContextKeyID)
|
||||||
|
|||||||
@@ -79,10 +79,14 @@ func NewService(opts ...Option) (Service, error) {
|
|||||||
r.Group(func(r chi.Router) {
|
r.Group(func(r chi.Router) {
|
||||||
r.Use(svc.DavUserContext())
|
r.Use(svc.DavUserContext())
|
||||||
|
|
||||||
|
r.Get("/remote.php/dav/spaces/{id}", svc.SpacesThumbnail)
|
||||||
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("/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("/remote.php/dav/files/{id}/*", svc.Thumbnail)
|
||||||
|
r.Get("/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 != "" {
|
if id != "" {
|
||||||
filePath = strings.TrimPrefix(filePath, path.Join("/remote.php/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("/dav/spaces", id))
|
||||||
|
|
||||||
filePath = strings.TrimPrefix(filePath, path.Join("/remote.php/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, path.Join("/dav/files", id))
|
||||||
|
filePath = strings.TrimPrefix(filePath, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = context.WithValue(ctx, constants.ContextKeyPath, filePath)
|
ctx = context.WithValue(ctx, constants.ContextKeyPath, filePath)
|
||||||
|
|||||||
Reference in new issue
Block a user