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