diff --git a/python/app/__init__.py b/python/app/__init__.py
index 25f0028..f37a33a 100644
--- a/python/app/__init__.py
+++ b/python/app/__init__.py
@@ -1,6 +1,5 @@
from __future__ import annotations
-import html as html_module
import itertools
import logging
import mimetypes
@@ -720,9 +719,10 @@ def _configure_logging(app: Flask) -> None:
return _website_error_response(status_code, "Not Found")
def _website_error_response(status_code, message):
- safe_msg = html_module.escape(str(message))
- safe_code = html_module.escape(str(status_code))
- body = f"
{safe_code} {safe_msg}{safe_code} {safe_msg}
"
+ if status_code == 404:
+ body = "404 page not found"
+ else:
+ body = f"{status_code} {message}"
return Response(body, status=status_code, mimetype="text/html")
@app.after_request
diff --git a/python/tests/test_website_hosting.py b/python/tests/test_website_hosting.py
index 71d8326..ae000b9 100644
--- a/python/tests/test_website_hosting.py
+++ b/python/tests/test_website_hosting.py
@@ -439,4 +439,4 @@ class TestWebsiteServing:
store.set_mapping("noerr.example.com", "no-err")
resp = website_client.get("/missing.html", headers={"Host": "noerr.example.com"})
assert resp.status_code == 404
- assert b"Not Found" in resp.data
+ assert resp.data == b"404 page not found"
diff --git a/rust/myfsio-engine/crates/myfsio-server/src/middleware/auth.rs b/rust/myfsio-engine/crates/myfsio-server/src/middleware/auth.rs
index 9715346..9a8f189 100644
--- a/rust/myfsio-engine/crates/myfsio-server/src/middleware/auth.rs
+++ b/rust/myfsio-engine/crates/myfsio-server/src/middleware/auth.rs
@@ -44,32 +44,12 @@ fn website_error_response(
fn default_website_error_body(status: StatusCode) -> String {
let code = status.as_u16();
- let reason = status.canonical_reason().unwrap_or("Error");
- format!(
- "\
-\
-\
-\
-\
-{code} {reason}\
-\
-\
-\
-\
-HTTP {code}
\
-{code} {reason}
\
-The requested page could not be found. Check the URL, or return to the site root.
\
-\
-\
-"
- )
+ if status == StatusCode::NOT_FOUND {
+ "404 page not found".to_string()
+ } else {
+ let reason = status.canonical_reason().unwrap_or("Error");
+ format!("{code} {reason}")
+ }
}
fn parse_range_header(range_header: &str, total_size: u64) -> Option<(u64, u64)> {
diff --git a/rust/myfsio-engine/crates/myfsio-server/tests/integration.rs b/rust/myfsio-engine/crates/myfsio-server/tests/integration.rs
index dc735e3..09767f9 100644
--- a/rust/myfsio-engine/crates/myfsio-server/tests/integration.rs
+++ b/rust/myfsio-engine/crates/myfsio-server/tests/integration.rs
@@ -3323,8 +3323,7 @@ async fn test_static_website_default_404_returns_html_body() {
)
.unwrap();
assert_eq!(body.len(), content_length);
- assert!(body.contains("404 Not Found
"));
- assert!(body.len() > 512);
+ assert_eq!(body, "404 page not found");
let head_resp = app
.oneshot(website_request(Method::HEAD, "/missing.html"))