From b4226e81464cff4fae1b76cb57b59f6d0e93d4fa Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Wed, 27 Jul 2016 15:55:02 -0500 Subject: [PATCH] Backport PR #7855 --------- **Commit 1:** Bump marked * Original sha: 7cf64c75a5d730798b66e50b52332ed407596433 * Authored by Jonathan Budzenski on 2016-07-21T18:44:47Z * Committed by Jonathan Budzenski on 2016-07-27T13:54:33Z --- bower.json | 5 ++- package.json | 3 -- .../vislib/visualizations/tile_map.js | 4 +- src/kibana/components/visualize/visualize.js | 3 +- .../markdown_vis/markdown_vis_controller.js | 7 +-- src/kibana/require.config.js | 1 + tasks/compile_dist_readme.js | 44 +++---------------- 7 files changed, 17 insertions(+), 50 deletions(-) diff --git a/bower.json b/bower.json index d3d5901a63112..915cd84f6e18a 100644 --- a/bower.json +++ b/bower.json @@ -47,10 +47,11 @@ "requirejs": "2.1.18", "requirejs-text": "2.0.14", "lodash-deep": "spenceralger/lodash-deep#1a7eca8344", - "marked": "0.3.3", + "marked": "0.3.5", "numeral": "1.5.3", "leaflet-draw": "0.2.4", - "semver": "~4.3.4" + "semver": "~4.3.4", + "angular-sanitize": "1.5.8" }, "devDependencies": {}, "resolutions": { diff --git a/package.json b/package.json index 46cdfc4a999a4..fb96795c1fde5 100644 --- a/package.json +++ b/package.json @@ -82,14 +82,11 @@ "grunt-run": "^0.2.3", "grunt-s3": "^0.2.0-alpha.3", "grunt-simple-mocha": "^0.4.0", - "html-entities": "^1.1.1", "http-proxy": "^1.8.1", "husky": "^0.6.0", "istanbul": "^0.2.4", "license-checker": "^3.1.0", "load-grunt-config": "^0.7.0", - "marked": "0.3.3", - "marked-text-renderer": "^0.1.0", "mkdirp": "^0.5.0", "mocha": "^2.2.5", "npm": "^2.15.8", diff --git a/src/kibana/components/vislib/visualizations/tile_map.js b/src/kibana/components/vislib/visualizations/tile_map.js index 3011253a2b24c..46793d5b2a187 100644 --- a/src/kibana/components/vislib/visualizations/tile_map.js +++ b/src/kibana/components/vislib/visualizations/tile_map.js @@ -1,5 +1,5 @@ define(function (require) { - return function TileMapFactory(d3, Private, configFile) { + return function TileMapFactory(d3, Private, configFile, $sanitize) { var _ = require('lodash'); var $ = require('jquery'); var L = require('leaflet'); @@ -84,7 +84,7 @@ define(function (require) { var div = $(this).addClass('tilemap'); var tileLayer = L.tileLayer(configFile.tilemap_url, { - attribution: marked(configFile.tilemap_attribution), + attribution: $sanitize(marked(configFile.tilemap_attribution)), subdomains: configFile.tilemap_subdomains, minZoom: configFile.tilemap_min_zoom, maxZoom: configFile.tilemap_max_zoom diff --git a/src/kibana/components/visualize/visualize.js b/src/kibana/components/visualize/visualize.js index 187d017879da2..51673356eb317 100644 --- a/src/kibana/components/visualize/visualize.js +++ b/src/kibana/components/visualize/visualize.js @@ -1,6 +1,7 @@ define(function (require) { + require('angular-sanitize'); require('modules') - .get('kibana/directive') + .get('kibana/directive', ['ngSanitize']) .directive('visualize', function (Notifier, SavedVis, indexPatterns, Private) { require('components/visualize/spy/spy'); diff --git a/src/kibana/plugins/markdown_vis/markdown_vis_controller.js b/src/kibana/plugins/markdown_vis/markdown_vis_controller.js index 591d2f8c1c352..d74a5ac1d554e 100644 --- a/src/kibana/plugins/markdown_vis/markdown_vis_controller.js +++ b/src/kibana/plugins/markdown_vis/markdown_vis_controller.js @@ -1,15 +1,16 @@ define(function (require) { var marked = require('marked'); + require('angular-sanitize'); marked.setOptions({ gfm: true, // Github-flavored markdown sanitize: true // Sanitize HTML tags }); - var module = require('modules').get('kibana/markdown_vis', ['kibana']); + var module = require('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); }); }); -}); \ No newline at end of file +}); diff --git a/src/kibana/require.config.js b/src/kibana/require.config.js index df1d370ce9f61..11ba9dd24eac5 100644 --- a/src/kibana/require.config.js +++ b/src/kibana/require.config.js @@ -13,6 +13,7 @@ require.config({ 'angular-bootstrap': 'bower_components/angular-bootstrap/ui-bootstrap-tpls', 'angular-elastic': 'bower_components/angular-elastic/elastic', 'angular-route': 'bower_components/angular-route/angular-route', + 'angular-sanitize': 'bower_components/angular-sanitize/angular-sanitize', 'angular-ui-ace': 'bower_components/angular-ui-ace/ui-ace', ace: 'bower_components/ace-builds/src-noconflict/ace', 'ace-json': 'bower_components/ace-builds/src-noconflict/mode-json', diff --git a/tasks/compile_dist_readme.js b/tasks/compile_dist_readme.js index 1b1dc6874c357..47931d3b32794 100644 --- a/tasks/compile_dist_readme.js +++ b/tasks/compile_dist_readme.js @@ -1,23 +1,6 @@ -var marked = require('marked'); var Promise = require('bluebird'); var join = require('path').join; -var TextRenderer = require('marked-text-renderer'); var _ = require('lodash'); -var fs = require('fs'); -var entities = new (require('html-entities').AllHtmlEntities)(); - -var readFile = Promise.promisify(fs.readFile); -var writeFile = Promise.promisify(fs.writeFile); - -TextRenderer.prototype.heading = function (text, level, raw) { - return '\n\n' + text + '\n' + _.map(text, function () { return '='; }).join('') + '\n'; -}; - -var process = function (input) { - var output = input.replace(/<\!\-\- [^\-]+ \-\->/g, '\n'); - output = marked(output); - return entities.decode(output); -}; module.exports = function (grunt) { @@ -32,29 +15,12 @@ module.exports = function (grunt) { var srcLicense = join(root, 'LICENSE.md'); var distLicense = join(build, 'dist', 'kibana', 'LICENSE.txt'); - marked.setOptions({ - renderer: new TextRenderer(), - tables: true, - breaks: false, - pedantic: false, - sanitize: false, - smartLists: true, - smartypants: false - }); - - readFile(srcReadme, 'utf-8') - .then(function (data) { - return writeFile(distReadme, process(data.toString())); - }) - .then(function () { - return readFile(srcLicense, 'utf-8'); - }) - .then(function (data) { - return writeFile(distLicense, process(data.toString())); - }) - .then(done) - .catch(done); + function transformReadme(readme) { + return readme.replace(/\s##\sSnapshot\sBuilds[\s\S]*/, ''); + } + grunt.file.copy(srcLicense, distLicense); + grunt.file.write(distReadme, transformReadme(grunt.file.read(srcReadme))); }); };