From 5dea3713a9aab1d45e554b1b566a67c20a2f6831 Mon Sep 17 00:00:00 2001 From: DCjanus Date: Thu, 7 Mar 2024 11:54:10 +0800 Subject: [PATCH] fix: shortest content disposition is 19 rather than 20 --- src/utils.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index 1f7b3a4..b15f92f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -11,6 +11,7 @@ pub(crate) const CRLFS: [u8; 4] = [b'\r', b'\n', b'\r', b'\n']; // `\r\n\r\n` const NAME: &[u8; 4] = b"name"; const FILE_NAME: &[u8; 8] = b"filename"; const FORM_DATA: &[u8; 9] = b"form-data"; +const SHORTEST_CONTENT_DISPOSITION: &[u8; 19] = b"form-data; name=\"s\""; pub(crate) fn parse_content_type(header: Option<&HeaderValue>) -> Option { header @@ -40,7 +41,7 @@ pub(crate) fn parse_part_headers(bytes: &[u8]) -> Result { #[allow(clippy::many_single_char_names)] pub(crate) fn parse_content_disposition(hv: &[u8]) -> Result<(String, Option)> { - if hv.len() < 20 { + if hv.len() < SHORTEST_CONTENT_DISPOSITION.len() { return Err(Error::InvalidContentDisposition); }