@reldens/server-utils 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app-server-factory.js +14 -2
- package/package.json +2 -2
|
@@ -13,7 +13,7 @@ const session = require('express-session');
|
|
|
13
13
|
const rateLimit = require('express-rate-limit');
|
|
14
14
|
const cors = require('cors');
|
|
15
15
|
const helmet = require('helmet');
|
|
16
|
-
const
|
|
16
|
+
const sanitizeHtml = require('sanitize-html');
|
|
17
17
|
|
|
18
18
|
class AppServerFactory
|
|
19
19
|
{
|
|
@@ -86,7 +86,19 @@ class AppServerFactory
|
|
|
86
86
|
this.app.use(this.rateLimit(limiterParams));
|
|
87
87
|
}
|
|
88
88
|
if(this.useXssProtection){
|
|
89
|
-
this.app.use(
|
|
89
|
+
this.app.use((req, res, next) => {
|
|
90
|
+
if(!req.body){
|
|
91
|
+
return next();
|
|
92
|
+
}
|
|
93
|
+
if(typeof req.body === 'object'){
|
|
94
|
+
for(let key in req.body){
|
|
95
|
+
if(typeof req.body[key] === 'string'){
|
|
96
|
+
req.body[key] = sanitizeHtml(req.body[key]);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
next();
|
|
101
|
+
});
|
|
90
102
|
}
|
|
91
103
|
if(this.useExpressJson){
|
|
92
104
|
this.app.use(this.applicationFramework.json({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reldens/server-utils",
|
|
3
3
|
"scope": "@reldens",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.0",
|
|
5
5
|
"description": "Reldens - Server Utils",
|
|
6
6
|
"author": "Damian A. Pastorini",
|
|
7
7
|
"license": "MIT",
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"express-session": "1.18.1",
|
|
43
43
|
"helmet": "8.1.0",
|
|
44
44
|
"multer": "^1.4.5-lts.2",
|
|
45
|
-
"
|
|
45
|
+
"sanitize-html": "^2.16.0"
|
|
46
46
|
}
|
|
47
47
|
}
|