Skip to content

fix(multipart): keep bare CR before boundary text as field data - #4376

Merged
robjtede merged 2 commits into
actix:mainfrom
b84330808:fix-multipart-bare-cr-delimiter
Nov 4, 2026
Merged

robjtede merged 2 commits into
actix:mainfrom
b84330808:fix-multipart-bare-cr-delimiter

Conversation

@b84330808

@b84330808 b84330808 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Type

Bug Fix

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

InnerField::read_stream ended a field (without a Content-Length) at a bare CR followed by -- and the boundary, not only at CRLF -- boundary. The rest of that line was then consumed as if it were the delimiter line, so the field data was silently cut short: one\r--abc two came back as one, with no error.

RFC 2046 §5.1.1 requires the delimiter to be preceded by CRLF, so this only treats \r\n-- plus the boundary as the end of a field, both in the check at the start of the buffer and in the scan loop. The new test covers the whole body in one chunk and a split where a chunk starts at the bare CR.

Closes #4356

I used Claude Code to write this change.

A boundary delimiter must be preceded by CRLF (RFC 2046 section 5.1.1), but
`InnerField::read_stream` also ended a field at a bare CR followed by `--`
and the boundary. The rest of that line was then consumed as if it were the
delimiter line, so field data was silently truncated.

Only treat `\r\n--` plus the boundary as the end of a field.

Closes actix#4356

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the A-multipart project: actix-multipart label Nov 2, 2026

@robjtede robjtede left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great find, thanks

@robjtede
robjtede enabled auto-merge November 4, 2026 16:01
@robjtede
robjtede added this pull request to the merge queue Nov 4, 2026
Merged via the queue into actix:main with commit 3396bd8 Nov 4, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-multipart project: actix-multipart B-semver-patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

actix-multipart: Bare CR followed by boundary text truncates multipart field data

2 participants