Sanitize text that gets sent to Gritter for notifications,

#198
pull/2/head
Kevan Ahlquist 2016-03-31 20:06:46 -05:00
parent b2b814a65b
commit 5bf922325a
4 changed files with 9 additions and 7 deletions

View File

@ -75,7 +75,7 @@ angular.module('dockerui', [
if (typeof(response.data) === 'string' && response.data.startsWith('Conflict.')) { if (typeof(response.data) === 'string' && response.data.startsWith('Conflict.')) {
$.gritter.add({ $.gritter.add({
title: 'Error', title: 'Error',
text: response.data, text: $('<div>').text(response.data).html(),
time: 10000 time: 10000
}); });
} }

View File

@ -1,4 +1,4 @@
angular.module('dockerui.services', ['ngResource']) angular.module('dockerui.services', ['ngResource', 'ngSanitize'])
.factory('Container', ['$resource', 'Settings', function ContainerFactory($resource, Settings) { .factory('Container', ['$resource', 'Settings', function ContainerFactory($resource, Settings) {
'use strict'; 'use strict';
// Resource for interacting with the docker containers // Resource for interacting with the docker containers
@ -171,13 +171,13 @@ angular.module('dockerui.services', ['ngResource'])
} }
}; };
}) })
.factory('Messages', ['$rootScope', function MessagesFactory($rootScope) { .factory('Messages', ['$rootScope', '$sanitize', function MessagesFactory($rootScope, $sanitize) {
'use strict'; 'use strict';
return { return {
send: function (title, text) { send: function (title, text) {
$.gritter.add({ $.gritter.add({
title: title, title: $sanitize(title),
text: text, text: $sanitize(text),
time: 2000, time: 2000,
before_open: function () { before_open: function () {
if ($('.gritter-item-wrapper').length === 3) { if ($('.gritter-item-wrapper').length === 3) {
@ -188,8 +188,8 @@ angular.module('dockerui.services', ['ngResource'])
}, },
error: function (title, text) { error: function (title, text) {
$.gritter.add({ $.gritter.add({
title: title, title: $sanitize(title),
text: text, text: $sanitize(text),
time: 10000, time: 10000,
before_open: function () { before_open: function () {
if ($('.gritter-item-wrapper').length === 4) { if ($('.gritter-item-wrapper').length === 4) {

View File

@ -23,6 +23,7 @@
"dependencies": { "dependencies": {
"Chart.js": "1.0.2", "Chart.js": "1.0.2",
"angular": "1.3.15", "angular": "1.3.15",
"angular-sanitize": "1.3.15",
"angular-bootstrap": "0.12.0", "angular-bootstrap": "0.12.0",
"angular-mocks": "1.3.15", "angular-mocks": "1.3.15",
"angular-oboe": "*", "angular-oboe": "*",

View File

@ -153,6 +153,7 @@ module.exports = function (grunt) {
}, },
angular: { angular: {
src: ['bower_components/angular/angular.js', src: ['bower_components/angular/angular.js',
'bower_components/angular-sanitize/angular-sanitize.js',
'bower_components/angular-route/angular-route.js', 'bower_components/angular-route/angular-route.js',
'bower_components/angular-resource/angular-resource.js', 'bower_components/angular-resource/angular-resource.js',
'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', 'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',