mygit

[UNMAINTAINED] A cgit/webgit alternative, written in Rust
Log | Files | Refs | README | LICENSE

commit 0b845cad3d6e76678e93f86707b700efe46fcbec
parent 4e8cadd8b1aeaacab24aa3f9076fdc5d989c705b
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun, 18 Jul 2021 21:57:29 -0700

Don't expose internal server error

Diffstat:
Msrc/errorpage.rs | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/errorpage.rs b/src/errorpage.rs @@ -25,10 +25,15 @@ impl<State: Clone + Send + Sync + 'static> Middleware<State> for ErrorToErrorpag // - RFC 7231 ยง 4.3.2 response.take_body(); } else { + let message = match status { + // don't expose 500 error + StatusCode::InternalServerError => "Internal Server Error".to_owned(), + _ => err.into_inner().to_string(), + }; response = ErrorTemplate { resource, status, - message: err.into_inner().to_string(), + message: message } .into(); response.set_status(status);