Revert "[5.6] Add whitelist for urls (#14613) (#14621)"

This reverts commit f5274c1bde.
This commit is contained in:
Court Ewing 2017-10-30 07:50:26 -04:00
parent 4bed1d76be
commit efd2403e60
2 changed files with 5 additions and 28 deletions

View file

@ -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('<span ng-non-bindable>www.elastic.co</span>');
expect(url.convert('elastic.co', 'html'))
.to.be('<span ng-non-bindable>elastic.co</span>');
expect(url.convert('elastic', 'html'))
.to.be('<span ng-non-bindable>elastic</span>');
expect(url.convert('ftp://elastic.co', 'html'))
.to.be('<span ng-non-bindable>ftp://elastic.co</span>');
});
});
});
});

View file

@ -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 `<img src="${url}" alt="${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]) {