Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -744,4 +744,17 @@ describe('ReactFlightDOMReply', () => {
// has closed but that's a bug in both ReactFlightReplyServer and ReactFlightClient.
// It just halts in this case.
});

it('cannot deserialize a Blob reference backed by a string', async () => {
const formData = new FormData();
formData.set('1', '-'.repeat(50000));
formData.set('0', JSON.stringify(['$B1']));
let error;
try {
await ReactServerDOMServer.decodeReply(formData, webpackServerMap);
} catch (x) {
error = x;
}
expect(error.message).toContain('Referenced Blob is not a Blob.');
});
});
5 changes: 4 additions & 1 deletion packages/react-server/src/ReactFlightReplyServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,10 @@ function parseModelString(
const blobKey = prefix + id;
// We should have this backingEntry in the store already because we emitted
// it before referencing it. It should be a Blob.
const backingEntry: Blob = (response._formData.get(blobKey): any);
const backingEntry = response._formData.get(blobKey);
if (!(backingEntry instanceof Blob)) {
throw new Error('Referenced Blob is not a Blob.');
}
return backingEntry;
}
case 'R': {
Expand Down
3 changes: 2 additions & 1 deletion scripts/error-codes/codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -566,5 +566,6 @@
"578": "Already initialized Iterator.",
"579": "Invalid data for bytes stream.",
"580": "Server Function has too many bound arguments. Received %s but the limit is %s.",
"581": "BigInt is too large. Received %s digits but the limit is %s."
"581": "BigInt is too large. Received %s digits but the limit is %s.",
"582": "Referenced Blob is not a Blob."
}
Loading