summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorMhykol <mchaeldonald62@pm.me>2025-01-12 23:48:54 -0500
committerMhykol <mchaeldonald62@pm.me>2025-01-12 23:48:54 -0500
commit86842546a8aad3d5fb43e614a795d62e2c13e657 (patch)
tree59d57b2c1306e71f0fe5ff33b72aab2946df02c2 /app.js
parent5afca9d9e0929c27abcda069dad6908668a578fd (diff)
Fixed decoding for malformed URLs
Diffstat (limited to 'app.js')
-rw-r--r--app.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/app.js b/app.js
index 68ca3cf..d027f05 100644
--- a/app.js
+++ b/app.js
@@ -59,6 +59,18 @@ class App {
app.use(helmet())
app.use(limiter)
}
+ app.use((req, res, next) => {
+ let err = null
+ try {
+ decodeURIComponent(req.path)
+ } catch(e) {
+ err = e
+ }
+ if (err){
+ return res.redirect(['http://', req.get('Host'), '/404'].join(''))
+ }
+ next()
+ })
app.route('*')
.get(this.#ValidateCookie, this.#Logger, (req, res) => {
@@ -169,6 +181,9 @@ class App {
}
})
})
+ .all((req, res, next) => {
+ res.send('Other requests called');
+ })
app.listen(3000)
}