mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-23 06:00:21 +08:00
fix: reduce code paths for querystrings
This commit is contained in:
parent
4e578e9b28
commit
e8f5450cb0
@ -521,6 +521,22 @@ class WebServerService extends BaseService {
|
|||||||
// app.use(helmet.referrerPolicy());
|
// app.use(helmet.referrerPolicy());
|
||||||
app.disable('x-powered-by');
|
app.disable('x-powered-by');
|
||||||
|
|
||||||
|
// remove object and array query parameters
|
||||||
|
app.use(function (req, res, next) {
|
||||||
|
for ( let k in req.query ) {
|
||||||
|
if ( req.query[k] === undefined || req.query[k] === null ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const allowed_types = ['string', 'number', 'boolean'];
|
||||||
|
if ( ! allowed_types.includes(typeof req.query[k]) ) {
|
||||||
|
req.query[k] = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('\x1B[36;1m======= ok???', req.query);
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
const uaParser = require('ua-parser-js');
|
const uaParser = require('ua-parser-js');
|
||||||
app.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
const ua_header = req.headers['user-agent'];
|
const ua_header = req.headers['user-agent'];
|
||||||
|
Loading…
Reference in New Issue
Block a user