Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #423

Closed
wants to merge 2 commits into from
Closed

Fixes #423

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions libs/modelParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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"
Expand Down