magiclen / rocket-multipart-form-data

This crate provides a multipart parser for the Rocket framework.
MIT License
35 stars 14 forks source link

Repetition Bug #12

Open joelawm opened 3 years ago

joelawm commented 3 years ago

Bug Reports

rocket = "0.4.10"

Windows 10 2004

The bug seems to be in the following code Broken:

 let upload_max: u32 = 10;

let options = MultipartFormDataOptions::with_multipart_form_data_fields(
     vec! [
            MultipartFormDataField::file("URL").
repetition(Repetition::fixed(upload_max))
.content_type_by_string(Some(mime::IMAGE_STAR)).unwrap(),
            MultipartFormDataField::text("body"),
        ]
);

Works:

let upload_max: u32 = 3;

let options = MultipartFormDataOptions::with_multipart_form_data_fields(
     vec! [
            MultipartFormDataField::file("URL").
repetition(Repetition::fixed(upload_max))
.content_type_by_string(Some(mime::IMAGE_STAR)).unwrap(),
            MultipartFormDataField::text("body"),
        ]
);

If I set the upload max to 3 the code works as expected and will upload the 3 files and finish the routine. If I go to 10 (my desired upload limit) it throws an error stating "The data type of field url is incorrect.". I looked through the source code a bit to see how the fixed() function works and I don't see anything inherently wrong with it. I also could be using this wrong, but it seems the max for the code was set higher than 10 as well. Any help would be appreciated!