Xuanwo opened a new pull request, #8924:
URL: https://github.com/apache/opendal/pull/8924

   # Which issue does this PR close?
   
   None. Found during maintenance; no separate issue was filed.
   
   # Rationale for this change
   
   `Multipart::parse` accepted malformed responses: a body without any boundary 
returned an empty part list, a truncated body missing the closing 
`--<boundary>--` returned a truncated part, and mid-line or prefix-colliding 
occurrences of the boundary string corrupted part bodies (a mid-line 
`--<boundary>--` even dropped all remaining parts). `MixedPart::parse` silently 
dropped header lines that did not contain the exact `": "` separator and 
overwrote duplicate headers. `parse_content_length` read only the first 
`Content-Length` header and accepted values such as `+10`.
   
   # What changes are included in this PR?
   
   - Parse multipart boundary delimiters per RFC 2046 §5.1.1: a delimiter 
starts at the beginning of the body or right after a CRLF, and its line may 
contain only optional transport padding before the CRLF. A closing 
`--<boundary>--` delimiter is required, so malformed or truncated bodies now 
fail with `ErrorKind::Unexpected`. Text that only resembles a boundary 
(`--<boundary>_extra`, mid-line occurrences) stays inside the part body.
   - Parse multipart part headers and inner HTTP response headers per RFC 9110 
§5.5: split on the first colon, trim leading and trailing spaces and tabs from 
the value, reject lines without a colon, and append duplicate fields instead of 
overwriting them.
   - Parse `Content-Length` per RFC 9112 §6.3 and RFC 9110 §8.6: field values 
must be non-empty ASCII digits, and duplicate fields must carry the same 
decimal value.
   
   Regression tests cover missing boundaries, truncated bodies, boundary-like 
body content, flexible and duplicate headers, and duplicate or malformed 
`Content-Length` values.
   
   # Are there any user-facing changes?
   
   Yes. OpenDAL now rejects malformed multipart responses and conflicting 
`Content-Length` headers with `ErrorKind::Unexpected` instead of silently 
accepting them. Well-formed responses are unaffected.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: Pi (v1.6.0)
   - Model: DeepSeek V4.1 Flash
   - Effort: max
   - Role: AI implemented the parsing fixes and regression tests, and ran the 
local format, clippy, unit test, and rustdoc checks. Verification uses unit 
tests with fabricated multipart and header inputs; no live GCS or Azure Blob 
behavior test was run. The human author remains accountable for the change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to