From 7cf64c75a5d730798b66e50b52332ed407596433 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Thu, 21 Jul 2016 13:44:47 -0500 Subject: [PATCH] Bump marked --- package.json | 5 ++-- .../public/markdown_vis_controller.js | 9 ++++-- .../public/directives/partials/truncated.html | 2 +- src/ui/public/directives/truncated.js | 5 ++-- src/ui/public/filters/markdown.js | 7 +++-- src/ui/public/vislib/visualizations/_map.js | 4 +-- src/ui/public/visualize/visualize.js | 4 ++- tasks/build/readme.js | 30 ++++--------------- 8 files changed, 26 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index ee6a487134f6a..1b986e1b6cd02 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,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", @@ -127,7 +128,7 @@ "less": "2.5.1", "less-loader": "2.2.0", "lodash": "3.10.1", - "marked": "0.3.3", + "marked": "0.3.5", "minimatch": "2.0.10", "mkdirp": "0.5.1", "moment": "2.13.0", @@ -178,7 +179,6 @@ "grunt-simple-mocha": "0.4.0", "gruntify-eslint": "1.0.1", "handlebars": "4.0.5", - "html-entities": "1.1.3", "husky": "0.8.1", "image-diff": "1.6.0", "intern": "3.2.3", @@ -193,7 +193,6 @@ "license-checker": "3.1.0", "load-grunt-config": "0.19.1", "makelogs": "3.0.2", - "marked-text-renderer": "0.1.0", "mocha": "2.3.0", "ncp": "2.0.0", "nock": "2.10.0", diff --git a/src/core_plugins/markdown_vis/public/markdown_vis_controller.js b/src/core_plugins/markdown_vis/public/markdown_vis_controller.js index de9e0a5902e9f..3888e47ea1027 100644 --- a/src/core_plugins/markdown_vis/public/markdown_vis_controller.js +++ b/src/core_plugins/markdown_vis/public/markdown_vis_controller.js @@ -1,14 +1,17 @@ import marked from 'marked'; import uiModules from 'ui/modules'; +import 'angular-sanitize'; + marked.setOptions({ gfm: true, // Github-flavored markdown sanitize: true // Sanitize HTML tags }); -const module = uiModules.get('kibana/markdown_vis', ['kibana']); -module.controller('KbnMarkdownVisController', function ($scope, $sce) { + +const module = uiModules.get('kibana/markdown_vis', ['kibana', 'ngSanitize']); +module.controller('KbnMarkdownVisController', function ($scope) { $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/directives/partials/truncated.html b/src/ui/public/directives/partials/truncated.html index 5a6810ff89adb..60e20567b7409 100644 --- a/src/ui/public/directives/partials/truncated.html +++ b/src/ui/public/directives/partials/truncated.html @@ -1,5 +1,5 @@ {{content}} - + {{action}} diff --git a/src/ui/public/directives/truncated.js b/src/ui/public/directives/truncated.js index 9583255ad8842..4d2773a241174 100644 --- a/src/ui/public/directives/truncated.js +++ b/src/ui/public/directives/truncated.js @@ -3,8 +3,9 @@ import truncText from 'trunc-text'; import truncHTML from 'trunc-html'; import uiModules from 'ui/modules'; import truncatedTemplate from 'ui/directives/partials/truncated.html'; -import 'ui/filters/trust_as_html'; -const module = uiModules.get('kibana'); +import 'angular-sanitize'; + +const module = uiModules.get('kibana', ['ngSanitize']); module.directive('kbnTruncated', function ($compile) { return { diff --git a/src/ui/public/filters/markdown.js b/src/ui/public/filters/markdown.js index c313c0996e743..210aa4e75f3b7 100644 --- a/src/ui/public/filters/markdown.js +++ b/src/ui/public/filters/markdown.js @@ -1,5 +1,6 @@ import marked from 'marked'; import uiModules from 'ui/modules'; +import 'angular-sanitize'; marked.setOptions({ gfm: true, // GitHub-flavored markdown @@ -7,7 +8,7 @@ marked.setOptions({ }); uiModules - .get('kibana') - .filter('markdown', function ($sce) { - return md => md ? $sce.trustAsHtml(marked(md)) : ''; + .get('kibana', ['ngSanitize']) + .filter('markdown', function ($sanitize) { + return md => md ? $sanitize(marked(md)) : ''; }); diff --git a/src/ui/public/vislib/visualizations/_map.js b/src/ui/public/vislib/visualizations/_map.js index 44aadba055b4b..b61de613488cd 100644 --- a/src/ui/public/vislib/visualizations/_map.js +++ b/src/ui/public/vislib/visualizations/_map.js @@ -11,14 +11,14 @@ import VislibVisualizationsMarkerTypesScaledCirclesProvider from 'ui/vislib/visu import VislibVisualizationsMarkerTypesShadedCirclesProvider from 'ui/vislib/visualizations/marker_types/shaded_circles'; import VislibVisualizationsMarkerTypesGeohashGridProvider from 'ui/vislib/visualizations/marker_types/geohash_grid'; import VislibVisualizationsMarkerTypesHeatmapProvider from 'ui/vislib/visualizations/marker_types/heatmap'; -export default function MapFactory(Private, tilemap) { +export default function MapFactory(Private, tilemap, $sanitize) { let defaultMapZoom = 2; let defaultMapCenter = [15, 5]; 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 45aed2c04c57e..3a040baed24d3 100644 --- a/src/ui/public/visualize/visualize.js +++ b/src/ui/public/visualize/visualize.js @@ -6,8 +6,10 @@ import _ from 'lodash'; import RegistryVisTypesProvider from 'ui/registry/vis_types'; import uiModules from 'ui/modules'; import visualizeTemplate from 'ui/visualize/visualize.html'; +import 'angular-sanitize'; + uiModules -.get('kibana/directive') +.get('kibana/directive', ['ngSanitize']) .directive('visualize', function (Notifier, SavedVis, indexPatterns, Private, config, $timeout) { 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'))); }); };