mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-01-31 17:10:11 +08:00
fix: use platform independent absolute path algorithm
Fixes issue https://github.com/hibiken/asynqmon/issues/257
This commit is contained in:
parent
5c48e4e31d
commit
724e77fc0c
@ -29,11 +29,7 @@ type uiAssetsHandler struct {
|
|||||||
// serve the file specified by the URL path.
|
// serve the file specified by the URL path.
|
||||||
func (h *uiAssetsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *uiAssetsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
// Get the absolute path to prevent directory traversal.
|
// Get the absolute path to prevent directory traversal.
|
||||||
path, err := filepath.Abs(r.URL.Path)
|
path := filepath.filepath.ToSlash(filepath.Clean(r.URL.Path))
|
||||||
if err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the path relative to the root path.
|
// Get the path relative to the root path.
|
||||||
if !strings.HasPrefix(path, h.rootPath) {
|
if !strings.HasPrefix(path, h.rootPath) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user