Merge pull request #3253 from quay/joseph.schorr/QUAY-981/logs-markdown

Only markdown strings in builder service when explicitly whitelisted
This commit is contained in:
Joseph Schorr 2018-09-20 15:27:14 -04:00 committed by GitHub
commit a1b9c1086d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,6 +26,10 @@ angular.module('quay').factory('StringBuilderService', ['$sce', 'UtilService', f
'manifest_digest': 'link'
};
var allowMarkdown = {
'description': true,
};
var filters = {
'obj': function(value) {
if (!value) { return []; }
@ -118,8 +122,12 @@ angular.module('quay').factory('StringBuilderService', ['$sce', 'UtilService', f
}
var safe = UtilService.textToSafeHtml(value);
var markedDown = UtilService.getMarkedDown(safe);
markedDown = markedDown.substr('<p>'.length, markedDown.length - '<p></p>'.length);
var result = safe;
if (allowMarkdown[key]) {
result = UtilService.getMarkedDown(result);
result = result.substr('<p>'.length, result.length - '<p></p>'.length);
}
var icon = fieldIcons[key];
if (icon) {
@ -127,12 +135,12 @@ angular.module('quay').factory('StringBuilderService', ['$sce', 'UtilService', f
icon = 'fa-' + icon;
}
markedDown = '<i class="fa ' + icon + '"></i>' + markedDown;
result = '<i class="fa ' + icon + '"></i>' + result;
}
var codeTag = opt_codetag || 'code';
description = description.replace('{' + prefix + key + '}',
'<' + codeTag + '>' + markedDown + '</' + codeTag + '>');
'<' + codeTag + '>' + result + '</' + codeTag + '>');
return description
}