mirror of
https://github.com/linuxserver/core.git
synced 2026-02-20 05:07:19 +08:00
decodeURIComponent can throw
fixes https://github.com/c9/newclient/issues/13386
This commit is contained in:
parent
d404d1ded9
commit
ab3913a429
@ -1,9 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
var Path = require("path");
|
||||
var error = require("http-error");
|
||||
|
||||
module.exports = function sanitzePreviewPath(req, res, next) {
|
||||
var normalized = Path.normalize(decodeURIComponent(req.params.path));
|
||||
|
||||
var normalized;
|
||||
try {
|
||||
normalized = Path.normalize(decodeURIComponent(req.params.path));
|
||||
} catch(e) {
|
||||
return next(new error.BadRequest("URI malformed"));
|
||||
}
|
||||
|
||||
// N.B. Path.normalize does not strip away when the path starts with "../"
|
||||
if (normalized)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user