GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(dicer): accept transport padding after a boundary delimiter by yxshee · Pull Request #238 · fastify/busboy

Conversation

@yxshee

@yxshee yxshee commented Nov 9, 2026

Copy link
Copy Markdown

Problem

A boundary delimiter line that carries whitespace between the boundary and its CRLF makes the parser lose the part that follows it:

const Busboy = require('@fastify/busboy')
const bb = new Busboy({ headers: { 'content-type': 'multipart/form-data; boundary=b' } })
bb.on('field', (name, value) => console.log('field', name, JSON.stringify(value)))
bb.on('finish', () => console.log('finish'))
bb.end(Buffer.from(
  '--b \r\n' +                                               // <- space after the boundary
  'Content-Disposition: form-data; name="a"\r\n\r\n1\r\n' +
  '--b\r\n' +
  'Content-Disposition: form-data; name="c"\r\n\r\n2\r\n' +
  '--b--\r\n'))
// field c "2"
// finish              <- "a" is gone, silently

A tab behaves the same. RFC 2046 §5.1.1 allows this explicitly (dash-boundary transport-padding CRLF, with transport-padding := *LWSP-char) and says: "Composers MUST NOT generate non-zero length transport padding, but receivers MUST be able to handle padding added by message transports." Go's mime/multipart parses the body above as two fields; both busboys drop the first one.

The reason is in Dicer._oninfo: after the boundary matched, the bytes that follow are checked for -- and everything else is handed to the header parser as the start of the next part's header block. \r\nContent-Disposition: … then starts with a line consisting of a single space, which HeaderParser._parseHeader treats as a folded continuation of a header that does not exist, so no header is recognised and Busboy skips the part.

Fix

Skip spaces and tabs between the boundary and the CRLF once the dash check has run. The padding may be split across writes, so when a chunk ends inside it the parser stays in the "just matched" state and continues on the next chunk. Padding after the closing delimiter (--b-- \r\n) already worked because the trailer bytes are ignored.

Found by comparing busboy, @fastify/busboy and Go's mime/multipart over generated multipart bodies; this was one of two divergences; the other (a part with headers but no body makes Busboy hang) is fixed in a separate PR.

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included — two new cases in test/types-multipart.test.js: padding with a space, a tab and a mix on three boundary lines plus the closing delimiter, and padding split across write() calls
  • documentation is changed or added — n/a
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@yxshee
fix(dicer): accept transport padding after a boundary delimiter
29698f2
RFC 2046 section 5.1.1 allows linear whitespace between a boundary and
the CRLF that ends its line ("dash-boundary transport-padding CRLF") and
requires receivers to handle it. Dicer handed those bytes to the header
parser as the first line of the next part's header block, where a line
of only a space or a tab counts as a continuation of a header that does
not exist, so the part that followed a padded boundary line was dropped
without any error.

Skip spaces and tabs after the dash check. The padding may be split
across writes, so when a chunk ends inside it stay in the just-matched
state and continue with the next chunk.
@yxshee yxshee closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@yxshee
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.