fix: improve getRawBody parsing & handle error(s)#1528
Merged
Conversation
lukeed
commented
May 23, 2021
| fulfil(null); | ||
| return; | ||
| } | ||
| const new_len = offset + Buffer.byteLength(chunk); |
Member
Author
There was a problem hiding this comment.
Using the chunk.length was a bug. Incoming chunks can be strings, but even if they're still Buffer instances, length is not always the same as byteLength, which is what content-length tracks
|
|
||
| if (type === 'application/octet-stream') { | ||
| fulfil(data); | ||
| return fulfil(data); |
Member
Author
There was a problem hiding this comment.
Without this return, then decoding continued (below)
benmccann
reviewed
May 23, 2021
benmccann
reviewed
May 25, 2021
Member
|
lgtm. I wonder if |
benmccann
reviewed
May 28, 2021
Member
|
I rebased this and am going to go ahead and merge it. We can always add more tests later |
sidharthv96
added a commit
to sidharthv96/kit
that referenced
this pull request
May 29, 2021
* 'master' of https://github.com/sveltejs/kit: Version Packages (next) (sveltejs#1543) type fixes for adapter-node and adapter-static (sveltejs#1578) Upgrade to Vite 2.3.3 (sveltejs#1580) fix: improve getRawBody parsing & handle error(s) (sveltejs#1528) create-svelte: add svelte-check for TS (sveltejs#1556) pass validated svelte config to adapters (sveltejs#1559) types: group related and reduce potential inconsistencies (sveltejs#1539) Use sveltekit tag on StackOverflow (sveltejs#1558) Fix create-svelte build-template script (sveltejs#1555) Remove err param from Polka .listen() callback (sveltejs#1550) bump: polka and sirv versions (sveltejs#1548) svelte-kit package (sveltejs#1499)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Tests
pnpm testand lint the project withpnpm lintChangesets
pnpx changesetand following the promptsSummary
getRawBodyutility did not handle the case where the supplied body actually exceeds theContent-Lengthheader. Added that logic. (This is impossible to spoof on Playwright/browser clients. Can add a test once a unit testing system is in place.)octect-streamrequest bodies were double-fulfilledrawBodytype interfaces (missingnullpossibility)getRawBodypossible error(s) in consumers/adaptersRelated to (but does not close) #1523