Skip to content

Commit

Permalink
Fix bug on avatar middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and 6543 committed Mar 23, 2021
1 parent 6198403 commit dfe21fa
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions routers/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/http"
"os"
"path"
"path/filepath"
"strings"
"text/template"
"time"
Expand Down Expand Up @@ -152,12 +153,21 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor
return
}

if !strings.HasPrefix(req.URL.RequestURI(), "/"+prefix) {
prefix := strings.Trim(prefix, "/")

if !strings.HasPrefix(req.URL.EscapedPath(), "/"+prefix+"/") {
return
}
rPath := strings.TrimPrefix(req.URL.EscapedPath(), "/"+prefix+"/")

rPath := strings.TrimPrefix(req.URL.RequestURI(), "/"+prefix)
rPath = strings.TrimPrefix(rPath, "/")
if rPath == "" {
ctx.Error(404, "file not found")
return
}
rPath = path.Clean("/" + filepath.ToSlash(rPath))
rPath = rPath[1:]

//If we have matched and access to release or issue
fr, err := objStore.Open(rPath)
if err != nil {
Expand Down

0 comments on commit dfe21fa

Please sign in to comment.