GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — fix(dicer): finish a part whose header block ends at the delimiter by yxshee · Pull Request #239 · fastify/busboy ConversationProblemA part that consists of headers only, with the delimiter following the last header line directly, makes Busboy hang: neither 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.on('error', err => console.log('error', err.message)) bb.end(Buffer.from( '--b\r\n' + 'Content-Disposition: form-data; name="x"\r\n' + // no empty line, no body '--b--\r\n')) // (nothing, ever) RFC 2046 §5.1.1 defines What happens inside Dicer: 'header' is only emitted when FixAt the match, if the header block of a (non-preamble) part is still open, finish the header parser before ending the part. The needle starts with CRLF, so the parser always holds complete header lines at that point; the part is then delivered like any other, with an empty body. Parts with no usable headers are skipped by With this change Found by comparing busboy, @fastify/busboy and Go's mime/multipart over generated multipart bodies (the other divergence, transport padding after a boundary line dropping the next part, is fixed in a separate PR). Checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsRFC 2046 section 5.1.1 makes the body of a part optional: a part may be nothing but headers, so the delimiter can follow the last header line directly instead of an empty line: --b\r\n Content-Disposition: form-data; name="x"\r\n --b-- Dicer only emitted 'header' when the header parser saw CRLF CRLF. When the boundary search matched first, the header parser was reset, the part never got a 'header' event, nobody read it, its 'end' never fired and Dicer never finished: Busboy emitted neither 'finish' nor 'error' and the request hung. Go's mime/multipart and busboy 1.x handle this input (the latter as an error). The needle starts with CRLF, so at the match the header parser always holds complete lines. Finish it there and emit the header, so the part is delivered with an empty body like any other.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. 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. |