From ef2d069e89d2723b9d98a613c9fcdfd5d7a4b796 Mon Sep 17 00:00:00 2001 From: Brian Quinn Date: Tue, 19 Apr 2016 09:50:45 +0100 Subject: [PATCH] Resolves #1021, passes a subset of attributes to Grunt replace task The grunt-replace module would fail if undefined or null values were passed. Passing a smaller list of course and config properties reduces the chances of that, and will speed up performance. --- grunt/config/replace.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grunt/config/replace.js b/grunt/config/replace.js index 2d2494766..793f8e3a6 100644 --- a/grunt/config/replace.js +++ b/grunt/config/replace.js @@ -1,5 +1,6 @@ var path = require('path'); var fs = require('fs'); +var _ = require('underscore'); module.exports = function (grunt, options) { @@ -37,6 +38,10 @@ module.exports = function (grunt, options) { } } + // Ensure that only whitelisted attributes can be replaced. + courseJson = _.pick(courseJson, 'title', 'displayTitle', 'body', 'description'); + configJson = _.pick(configJson, '_xapi', '_spoor'); + // Combine the course and config JSON so both can be passed to replace. var json = { 'course': courseJson, @@ -76,4 +81,4 @@ module.exports = function (grunt, options) { } } } -} \ No newline at end of file +}