From 274bb1a3d27f0d4388b61100b60c8c5a7356f71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 12 Sep 2026 21:33:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=B8=A6=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=9A=84=20PNG=20=E5=86=85=E5=AE=B9=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解析 multipart Content-Type 的媒体类型部分,接受合法的 image/png 参数。 --- server-rs/crates/api-server/src/raw_image.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server-rs/crates/api-server/src/raw_image.rs b/server-rs/crates/api-server/src/raw_image.rs index e7bb2ff53..106698345 100644 --- a/server-rs/crates/api-server/src/raw_image.rs +++ b/server-rs/crates/api-server/src/raw_image.rs @@ -278,7 +278,17 @@ async fn read_multipart_image( name: &str, total_bytes: &mut usize, ) -> Result { - let mime_type = field.content_type().unwrap_or_default().to_string(); + let mime_type = field + .content_type() + .map(|value| { + value + .split(';') + .next() + .unwrap_or_default() + .trim() + .to_string() + }) + .unwrap_or_default(); if !mime_type.eq_ignore_ascii_case("image/png") { return Err(bad_request(format!("{name} 必须为 image/png"))); }