diff --git a/app.js b/app.js index a1ee70da5..94dc2079b 100755 --- a/app.js +++ b/app.js @@ -2,13 +2,11 @@ var express = require('express'); var methodOverride = require('method-override'); -var morgan = require('morgan'); var bodyParser = require('body-parser'); var compression = require('compression'); var cookieParser = require('cookie-parser'); var favicon = require('serve-favicon'); -var minify = require('express-minify'); var session = require('express-session'); var MongoStore = require('connect-mongo')(session); var mongoose = require('mongoose'); @@ -52,7 +50,10 @@ if (app.get('port') === 443) { } if (process.env.NODE_ENV !== 'production') { - app.use(morgan('dev')); + try { + var morgan = require('morgan'); + app.use(morgan('dev')); + } catch (e) {} } app.use(bodyParser.urlencoded({ @@ -90,7 +91,10 @@ app.set('views', __dirname + '/views'); // Setup minification // Order is important here as Ace will fail with an invalid content encoding issue if (process.env.NODE_ENV === 'production') { - app.use(minify()); + try { + var minify = require('express-minify'); + app.use(minify()); + } catch (e) {} } // Routes diff --git a/libs/modelParser.js b/libs/modelParser.js index 7d739f44a..38682d088 100644 --- a/libs/modelParser.js +++ b/libs/modelParser.js @@ -126,6 +126,15 @@ var parseScript = function (aScriptData) { if (script.meta.icon64) { script.icon45Url = script.meta.icon64; } + // Icons: Validation + // Must be a data:image uri or start with https:// + var iconUrlRegex = /((^data:image\/(gif|png);base64,)|(^https:\/\/))/; + if (script.icon16Url && !iconUrlRegex.test(script.icon16Url)) { + delete script.icon16Url; + } + if (script.icon45Url && !iconUrlRegex.test(script.icon45Url)) { + delete script.icon45Url; + } // Support Url if (script.meta.supportURL) { diff --git a/package.json b/package.json index f154b016a..2aa3caaad 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "connect-mongo": "0.4.1", "cookie-parser": "1.3.3", "express": "3.18.2", - "express-minify": "0.0.11", "express-session": "1.9.1", "font-awesome": "4.2.0", "formidable": "1.0.15", @@ -25,7 +24,6 @@ "method-override": "2.3.0", "moment": "2.8.3", "mongoose": "3.8.19", - "morgan": "1.5.0", "mu2": "0.5.20", "octicons": "git://github.com/github/octicons.git#835ee02", "passport": "0.2.1", @@ -53,6 +51,10 @@ "serve-favicon": "2.1.6", "underscore": "1.7.0" }, + "optionalDependencies": { + "morgan": "1.5.0", + "express-minify": "0.0.11" + }, "repository": { "type": "git", "url": "https://github.com/OpenUserJs/OpenUserJS.org.git"