mirror of
https://git.sleeping.town/mirrors/foxy-moxy
synced 2024-12-22 14:25:31 +00:00
Sanitize user input seed.
This commit is contained in:
parent
b517805b1b
commit
64e0bbab47
2 changed files with 4 additions and 2 deletions
|
@ -21,6 +21,7 @@
|
|||
"chance": "^1.0.4",
|
||||
"express": "^4.14.0",
|
||||
"node-gyp": "^3.4.0",
|
||||
"sanitize-filename": "^1.6.1",
|
||||
"uuid": "^3.0.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var fs = require('fs');
|
||||
var express = require('express');
|
||||
var uuid = require('uuid/v4');
|
||||
var sanitize = require('sanitize-filename');
|
||||
var Canvas = require('canvas');
|
||||
|
||||
var Fox = require('./js/fox.js');
|
||||
|
@ -54,9 +55,9 @@ app.get('/:width', function(req, res) {
|
|||
|
||||
app.get('/:width/:seed', function(req, res) {
|
||||
var width = parseInt(req.params.width);
|
||||
var seed = req.params.seed;
|
||||
var seed = sanitize(req.params.seed);
|
||||
if (width === undefined) width = 400;
|
||||
if (seed === undefined) seed = uuid();
|
||||
if (!seed) seed = uuid();
|
||||
var fileName = writeFoxToDisk(width, width, seed);
|
||||
res.send('<img src="/' + fileName + '"/>');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue