Files
overleaf-cep/.yarn/patches/body-parser-npm-1.20.4-805a6a51d0.patch
Jakob Ackermann 81df324bcc [monorepo] prepare for zod everywhere epic (#36027)
GitOrigin-RevId: f082ae7fc7857fa72b2c1823645050bd4f6df305
2026-09-17 11:42:46 +00:00

133 lines
4.3 KiB
Diff

diff --git a/lib/read.js b/lib/read.js
index fce6283f50961e68c2f576031ed5e3d4fdc39984..6131c31fb8ba8d413e0a3bf887ebd87f1c3a4007 100644
--- a/lib/read.js
+++ b/lib/read.js
@@ -18,7 +18,7 @@ var iconv = require('iconv-lite')
var onFinished = require('on-finished')
var unpipe = require('unpipe')
var zlib = require('zlib')
-
+var Stream = require('stream')
/**
* Module exports.
*/
@@ -166,25 +166,25 @@ function contentstream (req, debug, inflate) {
case 'deflate':
stream = zlib.createInflate()
debug('inflate body')
- req.pipe(stream)
+ // req.pipe(stream)
break
case 'gzip':
stream = zlib.createGunzip()
debug('gunzip body')
- req.pipe(stream)
+ // req.pipe(stream)
break
case 'identity':
stream = req
stream.length = length
- break
+ return req
default:
throw createError(415, 'unsupported content encoding "' + encoding + '"', {
encoding: encoding,
type: 'encoding.unsupported'
})
}
-
- return stream
+ var pass = new Stream.PassThrough(); Stream.pipeline(req, stream, pass, () => {})
+ return pass
}
/**
diff --git a/lib/types/json.js b/lib/types/json.js
index 59f3f7e28f2416cac957b5e35dc78839a5019e0d..f23e52eca828a726f12e915f8ea52698d3761d68 100644
--- a/lib/types/json.js
+++ b/lib/types/json.js
@@ -17,6 +17,8 @@ var contentType = require('content-type')
var createError = require('http-errors')
var debug = require('debug')('body-parser:json')
var read = require('../read')
+var LOCKDOWN_INSTALLED = Symbol.for('overleaf.lockdown.installed')
+var LOCKDOWN_RAW_BODY = Symbol.for('overleaf.lockdown.rawBody')
var typeis = require('type-is')
/**
@@ -105,7 +107,7 @@ function json (options) {
return
}
- req.body = req.body || {}
+ req.body = (req[LOCKDOWN_INSTALLED] ? req[LOCKDOWN_RAW_BODY] : req.body) || {}
// skip requests without bodies
if (!typeis.hasBody(req)) {
diff --git a/lib/types/raw.js b/lib/types/raw.js
index f5d1b67475405284e3dac312f92ade101571329f..251780a624b09340b8a821974565fa330f9792b7 100644
--- a/lib/types/raw.js
+++ b/lib/types/raw.js
@@ -13,6 +13,8 @@
var bytes = require('bytes')
var debug = require('debug')('body-parser:raw')
var read = require('../read')
+var LOCKDOWN_INSTALLED = Symbol.for('overleaf.lockdown.installed')
+var LOCKDOWN_RAW_BODY = Symbol.for('overleaf.lockdown.rawBody')
var typeis = require('type-is')
/**
@@ -59,7 +61,7 @@ function raw (options) {
return
}
- req.body = req.body || {}
+ req.body = (req[LOCKDOWN_INSTALLED] ? req[LOCKDOWN_RAW_BODY] : req.body) || {}
// skip requests without bodies
if (!typeis.hasBody(req)) {
diff --git a/lib/types/text.js b/lib/types/text.js
index 083a00908a6299a8ef72f477983359f5675f82ef..4ea3ee88191bf02ecedf6c975d20144d4d7f2f47 100644
--- a/lib/types/text.js
+++ b/lib/types/text.js
@@ -14,6 +14,8 @@ var bytes = require('bytes')
var contentType = require('content-type')
var debug = require('debug')('body-parser:text')
var read = require('../read')
+var LOCKDOWN_INSTALLED = Symbol.for('overleaf.lockdown.installed')
+var LOCKDOWN_RAW_BODY = Symbol.for('overleaf.lockdown.rawBody')
var typeis = require('type-is')
/**
@@ -61,7 +63,7 @@ function text (options) {
return
}
- req.body = req.body || {}
+ req.body = (req[LOCKDOWN_INSTALLED] ? req[LOCKDOWN_RAW_BODY] : req.body) || {}
// skip requests without bodies
if (!typeis.hasBody(req)) {
diff --git a/lib/types/urlencoded.js b/lib/types/urlencoded.js
index 832992c2c3e0324c9bcb612a01f2fe2fb3e19414..4da13852cd5a89c97d8d7be2b81ba8fd62551f9e 100644
--- a/lib/types/urlencoded.js
+++ b/lib/types/urlencoded.js
@@ -18,6 +18,8 @@ var createError = require('http-errors')
var debug = require('debug')('body-parser:urlencoded')
var deprecate = require('depd')('body-parser')
var read = require('../read')
+var LOCKDOWN_INSTALLED = Symbol.for('overleaf.lockdown.installed')
+var LOCKDOWN_RAW_BODY = Symbol.for('overleaf.lockdown.rawBody')
var typeis = require('type-is')
/**
@@ -83,7 +85,7 @@ function urlencoded (options) {
return
}
- req.body = req.body || {}
+ req.body = (req[LOCKDOWN_INSTALLED] ? req[LOCKDOWN_RAW_BODY] : req.body) || {}
// skip requests without bodies
if (!typeis.hasBody(req)) {