Merge pull request +13387 from c9/ide-catch_uri_malformed_errors

decodeURIComponent can throw
pull/290/head
Fabian Jakobs 2016-04-13 09:20:00 +02:00
commit 988eb7c811
1 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -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)