Skip to content

Commit

Permalink
Revert "[5.6] Add whitelist for urls (elastic#14613) (elastic#14621)"
Browse files Browse the repository at this point in the history
This reverts commit f5274c1.
  • Loading branch information
epixa committed Oct 30, 2017
1 parent 4bed1d7 commit efd2403
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
26 changes: 4 additions & 22 deletions src/ui/public/stringify/__tests__/_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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');
});

Expand Down Expand Up @@ -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>');
});
});
});
});
7 changes: 1 addition & 6 deletions src/ui/public/stringify/types/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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]) {
Expand Down

0 comments on commit efd2403

Please sign in to comment.