From efd2403e605c9f695a87929083421ba09f3ac54e Mon Sep 17 00:00:00 2001 From: Court Ewing Date: Mon, 30 Oct 2017 07:50:26 -0400 Subject: [PATCH] Revert "[5.6] Add whitelist for urls (#14613) (#14621)" This reverts commit f5274c1bde7290af81dd155bd2552662750ef88c. --- src/ui/public/stringify/__tests__/_url.js | 26 ++++------------------- src/ui/public/stringify/types/url.js | 7 +----- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/ui/public/stringify/__tests__/_url.js b/src/ui/public/stringify/__tests__/_url.js index 6c44543ba224..2444766e5942 100644 --- a/src/ui/public/stringify/__tests__/_url.js +++ b/src/ui/public/stringify/__tests__/_url.js @@ -44,11 +44,11 @@ describe('Url Format', function () { describe('url template', function () { it('accepts a template', function () { - const url = new Url({ urlTemplate: 'http://{{ value }}' }); + const url = new Url({ urlTemplate: 'url: {{ value }}' }); const $a = unwrap($(url.convert('url', 'html'))); expect($a.is('a')).to.be(true); expect($a.size()).to.be(1); - expect($a.attr('href')).to.be('http://url'); + expect($a.attr('href')).to.be('url: url'); expect($a.attr('target')).to.be('_blank'); expect($a.children().size()).to.be(0); }); @@ -61,11 +61,11 @@ describe('Url Format', function () { describe('label template', function () { it('accepts a template', function () { - const url = new Url({ labelTemplate: 'extension: {{ value }}', urlTemplate: 'http://www.{{value}}.com' }); + const url = new Url({ labelTemplate: 'extension: {{ value }}' }); const $a = unwrap($(url.convert('php', 'html'))); expect($a.is('a')).to.be(true); expect($a.size()).to.be(1); - expect($a.attr('href')).to.be('http://www.php.com'); + expect($a.attr('href')).to.be('php'); expect($a.html()).to.be('extension: php'); }); @@ -109,23 +109,5 @@ describe('Url Format', function () { }); }); }); - - describe('whitelist', function () { - it('should spit out the raw value if the value is not in the whitelist', function () { - const url = new Url(); - - expect(url.convert('www.elastic.co', 'html')) - .to.be('www.elastic.co'); - - expect(url.convert('elastic.co', 'html')) - .to.be('elastic.co'); - - expect(url.convert('elastic', 'html')) - .to.be('elastic'); - - expect(url.convert('ftp://elastic.co', 'html')) - .to.be('ftp://elastic.co'); - }); - }); }); }); diff --git a/src/ui/public/stringify/types/url.js b/src/ui/public/stringify/types/url.js index 17c33845b11e..08543b8bfe57 100644 --- a/src/ui/public/stringify/types/url.js +++ b/src/ui/public/stringify/types/url.js @@ -8,7 +8,7 @@ import { getHighlightHtml } from 'ui/highlight'; export function stringifyUrl(Private) { const FieldFormat = Private(IndexPatternsFieldFormatProvider); - const whitelistUrlSchemes = ['http://', 'https://']; + _.class(Url).inherits(FieldFormat); function Url(params) { @@ -102,11 +102,6 @@ export function stringifyUrl(Private) { return `${imageLabel}`; default: - const inWhitelist = whitelistUrlSchemes.some(scheme => url.indexOf(scheme) === 0); - if (!inWhitelist) { - return url; - } - let linkLabel; if (hit && hit.highlight && hit.highlight[field.name]) {