[web] enforce size limit on individual files when cloning project (#35211)

* [web] enforce size limit on individual files when cloning project

Co-authored-by: Brian Gough <brian.gough@overleaf.com>

* [web] improve test coverage

* [agents] speed up running frontend tests

* [web] gracefully handle project too large error

---------

Co-authored-by: Brian Gough <brian.gough@overleaf.com>
GitOrigin-RevId: c7b35a3a9688e15a9bb51c61816da82d39e0d29d
This commit is contained in:
Jakob Ackermann
2026-09-17 11:20:03 +00:00
committed by Copybot
co-authored by Brian Gough
parent f62bd990d4
commit 84c6a68eae
13 changed files with 365 additions and 22 deletions
@@ -492,6 +492,11 @@ async function copyProjectBlob(req, res, next) {
)
return render.notFound(res)
}
if (query.sizeLimit > 0 && sourceBlob.getByteLength() > query.sizeLimit) {
return res.status(HTTPStatus.REQUEST_ENTITY_TOO_LARGE).json({
size: sourceBlob.getByteLength(),
})
}
// Exit early if the blob exists in the target project.
// This will also catch global blobs, which always exist.
if (targetBlob) {