兼容带参数的 PNG 内容类型

解析 multipart Content-Type 的媒体类型部分,接受合法的 image/png 参数。
This commit is contained in:
2026-09-12 21:33:06 +08:00
parent 8a96190db8
commit 274bb1a3d2
+11 -1
View File
@@ -278,7 +278,17 @@ async fn read_multipart_image(
name: &str,
total_bytes: &mut usize,
) -> Result<RawImageData, AppError> {
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")));
}