[8.6] Improve script URL detection logic (#150045) (#150093)

# Backport

This will backport the following commits from `main` to `8.6`:
- [Improve script URL detection logic
(#150045)](https://github.com/elastic/kibana/pull/150045)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Thomas
Watson","email":"watson@elastic.co"},"sourceCommit":{"committedDate":"2023-02-01T18:24:28Z","message":"Improve
script URL detection logic
(#150045)","sha":"3fbbbd4c24cc6942e6df643a97c8b46edb0f8d99","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","v8.7.0"],"number":150045,"url":"https://github.com/elastic/kibana/pull/150045","mergeCommit":{"message":"Improve
script URL detection logic
(#150045)","sha":"3fbbbd4c24cc6942e6df643a97c8b46edb0f8d99"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/150045","number":150045,"mergeCommit":{"message":"Improve
script URL detection logic
(#150045)","sha":"3fbbbd4c24cc6942e6df643a97c8b46edb0f8d99"}}]}]
BACKPORT-->

Co-authored-by: Thomas Watson <watson@elastic.co>
This commit is contained in:
Kibana Machine 2023-02-01 14:38:32 -05:00 committed by GitHub
parent b9c2e14aab
commit 4b09263a15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,8 +46,9 @@ function getColor(rules, colorKey, value) {
}
function sanitizeUrl(url) {
const { protocol } = parseUrl(url);
// eslint-disable-next-line no-script-url
if (parseUrl(url).protocol === 'javascript:') {
if (protocol === 'javascript:' || protocol === 'data:' || protocol === 'vbscript:') {
return '';
}
return url;