MultipartReader cannot detect boundary if the value of the boundary parameter is enclosed in quotation marks #31648
Labels
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Needs: Author Feedback
The author of this issue needs to respond in order for us to continue investigating this issue.
Describe the bug
When using MultipartReader to read a request, the ReadNextSectionAsync method will throw an exception if the
boundary
parameter value in theContent-Type
header is enclosed in double-quotes.This is probably because
MultipartReader
strictly compares the boundary in the request body with the value of theboundary
parameter. Since they do not match, it fails to detect the boundary in the body.If you use the MultipartContent class to construct a multipart request, it will always enclose the
boundary
parameter value in double-quotes. So, theMultipartReader
will not be able to process requests generated byMultipartContent
.RFC 2045 §5.1 specifies that the value of the
boundary
parameter is the same regardless of the enclosing quotation marks.To Reproduce
You can get the reproduction code in this repository.
Exceptions
Workarounds
When creating an instance of
MultipartReader
, remove the double-quotes from the value pass to its constructor'sboundary
parameter, and it will work.For example:
Further technical details
ASP.NET Core version
5.0
Include the output of
dotnet --info
The text was updated successfully, but these errors were encountered: