mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 12:04:46 +00:00
Merge pull request #2666 from overleaf/em-max-json-request-size
Separate max_doc_length from max JSON request size GitOrigin-RevId: 4c725028111966bf04109080d80d4672273dd697
This commit is contained in:
parent
d717ebb2e0
commit
c301d8bc25
3 changed files with 13 additions and 6 deletions
|
@ -83,11 +83,7 @@ app.set('view engine', 'pug')
|
|||
Modules.loadViewIncludes(app)
|
||||
|
||||
app.use(bodyParser.urlencoded({ extended: true, limit: '2mb' }))
|
||||
// Make sure we can process twice the max doc length, to allow for
|
||||
// - the doc content
|
||||
// - text ranges spanning the whole doc
|
||||
// Also allow some overhead for JSON encoding
|
||||
app.use(bodyParser.json({ limit: 2 * Settings.max_doc_length + 64 * 1024 })) // 64kb overhead
|
||||
app.use(bodyParser.json({ limit: Settings.max_json_request_size }))
|
||||
app.use(methodOverride())
|
||||
app.use(bearerToken())
|
||||
|
||||
|
|
|
@ -429,6 +429,17 @@ module.exports = settings =
|
|||
# Maximum size of text documents in the real-time editing system.
|
||||
max_doc_length: 2 * 1024 * 1024 # 2mb
|
||||
|
||||
# Maximum JSON size in HTTP requests
|
||||
# We should be able to process twice the max doc length, to allow for
|
||||
# - the doc content
|
||||
# - text ranges spanning the whole doc
|
||||
#
|
||||
# There's also overhead required for the JSON encoding and the UTF-8 encoding,
|
||||
# theoretically up to 3 times the max doc length. On the other hand, we don't
|
||||
# want to block the event loop with JSON parsing, so we try to find a
|
||||
# practical compromise.
|
||||
max_json_request_size: parseInt(process.env["MAX_JSON_REQUEST_SIZE"]) || 6 * 1024 * 1024 # 6 MB
|
||||
|
||||
# Internal configs
|
||||
# ----------------
|
||||
path:
|
||||
|
|
|
@ -2,7 +2,7 @@ const Settings = require('settings-sharelatex')
|
|||
const request = require('./helpers/request')
|
||||
|
||||
// create a string that is longer than the max allowed (as defined in Server.js)
|
||||
const wayTooLongString = 'a'.repeat(2 * Settings.max_doc_length + 64 * 1024 + 1)
|
||||
const wayTooLongString = 'a'.repeat(Settings.max_json_request_size + 1)
|
||||
|
||||
describe('BodyParserErrors', function() {
|
||||
describe('when request is too large', function() {
|
||||
|
|
Loading…
Add table
Reference in a new issue