Skip to content

Commit

Permalink
Merge pull request #29 from DCjanus/main
Browse files Browse the repository at this point in the history
fix: shortest content disposition is 19 rather than 20
  • Loading branch information
fundon authored Mar 7, 2024
2 parents 9110b0c + 5dea371 commit 57be232
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<mime::Mime> {
header
Expand Down Expand Up @@ -40,7 +41,7 @@ pub(crate) fn parse_part_headers(bytes: &[u8]) -> Result<HeaderMap> {

#[allow(clippy::many_single_char_names)]
pub(crate) fn parse_content_disposition(hv: &[u8]) -> Result<(String, Option<String>)> {
if hv.len() < 20 {
if hv.len() < SHORTEST_CONTENT_DISPOSITION.len() {
return Err(Error::InvalidContentDisposition);
}

Expand Down

0 comments on commit 57be232

Please # to comment.