Skip to content

Commit

Permalink
fix: lint issue on tinfoilMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
DblK committed Dec 29, 2021
1 parent 19372a5 commit 76713da
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions security.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ func tinfoilMiddleware(next http.Handler) http.Handler {
return
}

// Remove pending "/" if exists
actualPath := r.RequestURI[1:]
if r.RequestURI[len(r.RequestURI)-1:] == "/" {
actualPath = r.RequestURI[1 : len(r.RequestURI)-1]
}

if r.RequestURI == "/" || utils.IsValidFilter(actualPath) {
if r.RequestURI == "/" || utils.IsValidFilter(cleanPath(r.RequestURI)) {
// Check for blacklist/whitelist
var uid = strings.Join(headers["Uid"], "")
if config.GetConfig().IsBlacklisted(uid) {
Expand Down Expand Up @@ -69,3 +63,11 @@ func tinfoilMiddleware(next http.Handler) http.Handler {
next.ServeHTTP(w, r)
})
}

func cleanPath(path string) string {
actualPath := path[1:]
if path[len(path)-1:] == "/" {
actualPath = path[1 : len(path)-1]
}
return actualPath
}

0 comments on commit 76713da

Please sign in to comment.