Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure to error when setting too large of preview data (#10831)
* Make sure to error when setting too large of preview data * Update to check size after signing and limit to 2KB
- Loading branch information
1 parent
a4eef95
commit 0f0398c
Showing
5 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
11 changes: 10 additions & 1 deletion
11
test/integration/getserversideprops-preview/pages/api/preview.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
export default (req, res) => { | ||
res.setPreviewData(req.query) | ||
if (req.query.tooBig) { | ||
try { | ||
res.setPreviewData(new Array(2000).fill('a').join('')) | ||
} catch (err) { | ||
return res.status(500).end('too big') | ||
} | ||
} else { | ||
res.setPreviewData(req.query) | ||
} | ||
|
||
res.status(200).end() | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
export default (req, res) => { | ||
res.setPreviewData(req.query) | ||
if (req.query.tooBig) { | ||
try { | ||
res.setPreviewData(new Array(2000).fill('a').join('')) | ||
} catch (err) { | ||
return res.status(500).end('too big') | ||
} | ||
} else { | ||
res.setPreviewData(req.query) | ||
} | ||
|
||
res.status(200).end() | ||
} |
This file contains 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