Use max_doc_length setting to limit incoming doc size

This commit is contained in:
Eric Mc Sween 2020-05-11 11:15:37 -04:00
parent cb959ddfc1
commit a2a1914a53

View file

@ -3,13 +3,12 @@ const HistoryManager = require('./HistoryManager')
const ProjectManager = require('./ProjectManager')
const Errors = require('./Errors')
const logger = require('logger-sharelatex')
const Settings = require('settings-sharelatex')
const Metrics = require('./Metrics')
const ProjectFlusher = require('./ProjectFlusher')
const DeleteQueueManager = require('./DeleteQueueManager')
const async = require('async')
const TWO_MEGABYTES = 2 * 1024 * 1024
module.exports = {
getDoc,
getProjectDocsAndFlushIfOld,
@ -134,7 +133,7 @@ function setDoc(req, res, next) {
const projectId = req.params.project_id
const { lines, source, user_id: userId, undoing } = req.body
const lineSize = _getTotalSizeOfLines(lines)
if (lineSize > TWO_MEGABYTES) {
if (lineSize > Settings.max_doc_length) {
logger.log(
{ projectId, docId, source, lineSize, userId },
'document too large, returning 406 response'