diff --git a/package.json b/package.json index fa4264de97416..4adda05db7282 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "angular-bootstrap-colorpicker": "3.0.19", "angular-elastic": "2.5.0", "angular-route": "1.4.7", + "angular-sanitize": "1.5.7", "ansicolors": "0.3.2", "autoprefixer": "5.1.1", "autoprefixer-loader": "2.0.0", @@ -117,7 +118,7 @@ "less-loader": "2.2.0", "loader-utils": "0.2.11", "lodash": "3.10.1", - "marked": "0.3.3", + "marked": "0.3.5", "minimatch": "2.0.10", "mkdirp": "0.5.1", "moment": "2.10.6", @@ -160,7 +161,6 @@ "grunt-s3": "0.2.0-alpha.3", "grunt-simple-mocha": "0.4.0", "gruntify-eslint": "1.0.1", - "html-entities": "1.1.3", "husky": "0.8.1", "intern": "3.2.3", "istanbul-instrumenter-loader": "0.1.3", @@ -175,7 +175,6 @@ "license-checker": "3.1.0", "load-grunt-config": "0.7.2", "makelogs": "2.0.0", - "marked-text-renderer": "0.1.0", "mocha": "2.3.0", "nock": "2.10.0", "npm": "2.15.8", diff --git a/src/plugins/markdown_vis/public/markdown_vis_controller.js b/src/plugins/markdown_vis/public/markdown_vis_controller.js index 00b859702edd5..9f8ad8cc21e34 100644 --- a/src/plugins/markdown_vis/public/markdown_vis_controller.js +++ b/src/plugins/markdown_vis/public/markdown_vis_controller.js @@ -1,15 +1,17 @@ define(function (require) { const marked = require('marked'); + require('angular-sanitize'); + marked.setOptions({ gfm: true, // Github-flavored markdown sanitize: true // Sanitize HTML tags }); - const module = require('ui/modules').get('kibana/markdown_vis', ['kibana']); + const module = require('ui/modules').get('kibana/markdown_vis', ['kibana', 'ngSanitize']); module.controller('KbnMarkdownVisController', function ($scope, $sce) { $scope.$watch('vis.params.markdown', function (html) { if (!html) return; - $scope.html = $sce.trustAsHtml(marked(html)); + $scope.html = marked(html); }); }); }); diff --git a/src/ui/public/vislib/visualizations/_map.js b/src/ui/public/vislib/visualizations/_map.js index 30f6d92496f21..584edeffa3943 100644 --- a/src/ui/public/vislib/visualizations/_map.js +++ b/src/ui/public/vislib/visualizations/_map.js @@ -1,5 +1,5 @@ define(function (require) { - return function MapFactory(Private, tilemap) { + return function MapFactory(Private, tilemap, $sanitize) { let _ = require('lodash'); let $ = require('jquery'); let L = require('leaflet'); @@ -14,7 +14,7 @@ define(function (require) { let defaultMarkerType = 'Scaled Circle Markers'; let tilemapOptions = tilemap.options; - let attribution = marked(tilemapOptions.attribution); + let attribution = $sanitize(marked(tilemapOptions.attribution)); let mapTiles = { url: tilemap.url, diff --git a/src/ui/public/visualize/visualize.js b/src/ui/public/visualize/visualize.js index 522764dd21ac2..5b0e1b190e11b 100644 --- a/src/ui/public/visualize/visualize.js +++ b/src/ui/public/visualize/visualize.js @@ -1,6 +1,8 @@ define(function (require) { + require('angular-sanitize'); + require('ui/modules') - .get('kibana/directive') + .get('kibana/directive', ['ngSanitize']) .directive('visualize', function (Notifier, SavedVis, indexPatterns, Private, config, $timeout) { require('ui/visualize/spy'); diff --git a/tasks/build/readme.js b/tasks/build/readme.js index a89039dba9f73..aa139c1df400f 100644 --- a/tasks/build/readme.js +++ b/tasks/build/readme.js @@ -1,37 +1,17 @@ let marked = require('marked'); let Promise = require('bluebird'); let { join } = require('path'); -let TextRenderer = require('marked-text-renderer'); let _ = require('lodash'); let fs = require('fs'); -let { AllHtmlEntities } = require('html-entities'); -let entities = new AllHtmlEntities(); - -TextRenderer.prototype.heading = function (text, level, raw) { - return '\n\n' + text + '\n' + _.map(text, function () { return '='; }).join('') + '\n'; -}; module.exports = function (grunt) { - grunt.registerTask('_build:readme', function () { - let transform = function (input) { - let output = input.replace(/<\!\-\- [^\-]+ \-\->/g, '\n'); - output = marked(output); - return entities.decode(output); - }; - - marked.setOptions({ - renderer: new TextRenderer(), - tables: true, - breaks: false, - pedantic: false, - sanitize: false, - smartLists: true, - smartypants: false - }); + function transformReadme(readme) { + return readme.replace(/\s##\sSnapshot\sBuilds[\s\S]*/, ''); + } - grunt.file.write('build/kibana/README.txt', transform(grunt.file.read('README.md'))); - grunt.file.write('build/kibana/LICENSE.txt', transform(grunt.file.read('LICENSE.md'))); + grunt.file.copy('LICENSE.md', 'build/kibana/LICENSE.txt'); + grunt.file.write('build/kibana/README.txt', transformReadme(grunt.file.read('README.md'))); }); };