mirror of
https://github.com/gin-gonic/gin.git
synced 2026-11-23 11:33:37 +08:00
Merge 00a07adccf5a93610ab424d00ed739ee716c3a4b into 3b08cd7235bd5ad2f055aa9e38135f111f6c5926
This commit is contained in:
commit
82b8ab0b16
@ -263,6 +263,10 @@ func (group *RouterGroup) createStaticHandler(relativePath string, fs http.FileS
|
||||
}
|
||||
|
||||
file := c.Param("filepath")
|
||||
// Clean the path to handle trailing slashes and invalid paths.
|
||||
// Many fs.FS implementations (e.g. fs.Sub, http.FS) reject paths with
|
||||
// trailing slashes because fs.ValidPath considers them invalid.
|
||||
file = path.Clean(file)
|
||||
// Check if file exists and/or if we have permission to access it
|
||||
f, err := fs.Open(file)
|
||||
if err != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user