Disallow additional paths, closes #123

This commit is contained in:
Jake 2015-06-24 00:50:38 -05:00
parent 58a2f0662d
commit f1fd92f1cf
4 changed files with 37 additions and 1 deletions

View File

@ -33,6 +33,15 @@ module.exports = function(req, callback) {
var def = req.url.query.default;
var helm = req.url.query.hasOwnProperty("helm");
// check for extra paths
if (req.url.path_list.length > 2) {
callback({
status: -2,
body: "Invalid URL Path"
});
return;
}
// Prevent app from crashing/freezing
if (size < config.min_size || size > config.max_size) {
// "Unprocessable Entity", valid request, but semantically erroneous:

View File

@ -4,10 +4,19 @@ var cache = require("../cache");
// GET cape request
module.exports = function(req, callback) {
var userId = (req.url.pathname.split("/")[2] || "").split(".")[0];
var userId = (req.url.path_list[1] || "").split(".")[0];
var def = req.url.query.default;
var rid = req.id;
// check for extra paths
if (req.url.path_list.length > 2) {
callback({
status: -2,
body: "Invalid URL Path"
});
return;
}
if (!helpers.id_valid(userId)) {
callback({
status: -2,

View File

@ -47,6 +47,15 @@ module.exports = function(req, callback) {
var scale = parseInt(req.url.query.scale) || config.default_scale;
var helm = req.url.query.hasOwnProperty("helm");
// check for extra paths
if (req.url.path_list.length > 3) {
callback({
status: -2,
body: "Invalid URL Path"
});
return;
}
// validate type
if (raw_type !== "body" && raw_type !== "head") {
callback({

View File

@ -40,6 +40,15 @@ module.exports = function(req, callback) {
var def = req.url.query.default;
var rid = req.id;
// check for extra paths
if (req.url.path_list.length > 2) {
callback({
status: -2,
body: "Invalid URL Path"
});
return;
}
if (!helpers.id_valid(userId)) {
callback({
status: -2,