mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
Disallow additional paths, closes #123
This commit is contained in:
parent
58a2f0662d
commit
f1fd92f1cf
@ -33,6 +33,15 @@ module.exports = function(req, callback) {
|
|||||||
var def = req.url.query.default;
|
var def = req.url.query.default;
|
||||||
var helm = req.url.query.hasOwnProperty("helm");
|
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
|
// Prevent app from crashing/freezing
|
||||||
if (size < config.min_size || size > config.max_size) {
|
if (size < config.min_size || size > config.max_size) {
|
||||||
// "Unprocessable Entity", valid request, but semantically erroneous:
|
// "Unprocessable Entity", valid request, but semantically erroneous:
|
||||||
|
|||||||
@ -4,10 +4,19 @@ var cache = require("../cache");
|
|||||||
|
|
||||||
// GET cape request
|
// GET cape request
|
||||||
module.exports = function(req, callback) {
|
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 def = req.url.query.default;
|
||||||
var rid = req.id;
|
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)) {
|
if (!helpers.id_valid(userId)) {
|
||||||
callback({
|
callback({
|
||||||
status: -2,
|
status: -2,
|
||||||
|
|||||||
@ -47,6 +47,15 @@ module.exports = function(req, callback) {
|
|||||||
var scale = parseInt(req.url.query.scale) || config.default_scale;
|
var scale = parseInt(req.url.query.scale) || config.default_scale;
|
||||||
var helm = req.url.query.hasOwnProperty("helm");
|
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
|
// validate type
|
||||||
if (raw_type !== "body" && raw_type !== "head") {
|
if (raw_type !== "body" && raw_type !== "head") {
|
||||||
callback({
|
callback({
|
||||||
|
|||||||
@ -40,6 +40,15 @@ module.exports = function(req, callback) {
|
|||||||
var def = req.url.query.default;
|
var def = req.url.query.default;
|
||||||
var rid = req.id;
|
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)) {
|
if (!helpers.id_valid(userId)) {
|
||||||
callback({
|
callback({
|
||||||
status: -2,
|
status: -2,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user