diff --git a/package.json b/package.json index d619ed9..121bea8 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/server.js b/server.js index 344884b..5205be9 100644 --- a/server.js +++ b/server.js @@ -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(''); });