diff --git a/server/src/lib.rs b/server/src/lib.rs index 48a6477..25e7727 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -37,8 +37,8 @@ fn init() -> Router { .get("x-request-id") .and_then(|value| value.to_str().ok()) { - Some(v) => v.to_string(), - None => String::from("unknown"), + Some(v) if v.chars().all(|c| c.is_alphanumeric()) => v.to_string(),// 确保请求ID只包含字母和数字 + _ => String::from("unknown"), }; tracing::error_span!("request_id", id = req_id) });