[8.x] [Discover] mailto links in data view urls (#200070) (#200220)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Discover] mailto links in data view urls
(#200070)](https://github.com/elastic/kibana/pull/200070)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Graham
Hudgins","email":"graham@elastic.co"},"sourceCommit":{"committedDate":"2024-11-14T13:30:10Z","message":"[Discover]
mailto links in data view urls (#200070)\n\nAdds `mailto:` as an allowed
URL Url formatters in data
views.","sha":"d7a913f183cfe35efe7f42bb2d46990abc07296d","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","v9.0.0","Team:DataDiscovery"],"number":200070,"url":"https://github.com/elastic/kibana/pull/200070","mergeCommit":{"message":"[Discover]
mailto links in data view urls (#200070)\n\nAdds `mailto:` as an allowed
URL Url formatters in data
views.","sha":"d7a913f183cfe35efe7f42bb2d46990abc07296d"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200070","number":200070,"mergeCommit":{"message":"[Discover]
mailto links in data view urls (#200070)\n\nAdds `mailto:` as an allowed
URL Url formatters in data
views.","sha":"d7a913f183cfe35efe7f42bb2d46990abc07296d"}}]}]
BACKPORT-->

Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
This commit is contained in:
Graham Hudgins 2024-11-18 04:30:02 -05:00 committed by GitHub
parent 1bdc587d4f
commit 5cae0bf848
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -19,6 +19,14 @@ describe('UrlFormat', () => {
);
});
test('outputs a mailto: link when URL starts with mailto:', () => {
const url = new UrlFormat({});
expect(url.convert('mailto:test@example.com', HTML_CONTEXT_TYPE)).toBe(
'<a href="mailto:test@example.com" target="_blank" rel="noopener noreferrer">mailto:test@example.com</a>'
);
});
test('outputs an <audio> if type === "audio"', () => {
const url = new UrlFormat({ type: 'audio' });

View file

@ -21,7 +21,7 @@ import {
} from '../types';
const templateMatchRE = /{{([\s\S]+?)}}/g;
const allowedUrlSchemes = ['http://', 'https://'];
const allowedUrlSchemes = ['http://', 'https://', 'mailto:'];
const URL_TYPES = [
{