mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 02:28:15 +03:00
webserver: don't raise a 500 server error for static file requests with overlong names
The Open call returns an errno ENAMETOOLONG. We didn't handle that specially, so turned it into a "500 internal server error" response. When serving static files, we should just return "404 file not found" errors. The file obviously does not exist. Saw a few overlong requests from bad bots not recognizing "data:" uri's inlined in html files, trying to request them.
This commit is contained in:
parent
06b7c8bba0
commit
aa2b24d861
@ -215,6 +215,9 @@ func HandleStatic(h *config.WebStatic, compress bool, w http.ResponseWriter, r *
|
||||
}
|
||||
http.NotFound(w, r)
|
||||
return true
|
||||
} else if errors.Is(err, syscall.ENAMETOOLONG) {
|
||||
http.NotFound(w, r)
|
||||
return true
|
||||
} else if os.IsPermission(err) {
|
||||
// If we tried opening a directory, we may not have permission to read it, but
|
||||
// still access files inside it (execute bit), such as index.html. So try to serve it.
|
||||
|
Loading…
x
Reference in New Issue
Block a user