TablePabel: Sanitize column link (#21735)
This commit is contained in:
committed by
Torkel Ödegaard
parent
089162b0be
commit
751eb2c8bb
@@ -14,6 +14,7 @@ import {
|
|||||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
import { ColumnRender, TableRenderModel, ColumnStyle } from './types';
|
import { ColumnRender, TableRenderModel, ColumnStyle } from './types';
|
||||||
import { ColumnOptionsCtrl } from './column_options';
|
import { ColumnOptionsCtrl } from './column_options';
|
||||||
|
import { sanitizeUrl } from 'app/core/utils/text';
|
||||||
|
|
||||||
export class TableRenderer {
|
export class TableRenderer {
|
||||||
formatters: any[];
|
formatters: any[];
|
||||||
@@ -297,13 +298,15 @@ export class TableRenderer {
|
|||||||
scopedVars['__cell'] = { value: value, text: value ? value.toString() : '' };
|
scopedVars['__cell'] = { value: value, text: value ? value.toString() : '' };
|
||||||
|
|
||||||
const cellLink = this.templateSrv.replace(column.style.linkUrl, scopedVars, encodeURIComponent);
|
const cellLink = this.templateSrv.replace(column.style.linkUrl, scopedVars, encodeURIComponent);
|
||||||
|
const sanitizedCellLink = sanitizeUrl(cellLink);
|
||||||
|
|
||||||
const cellLinkTooltip = this.templateSrv.replace(column.style.linkTooltip, scopedVars);
|
const cellLinkTooltip = this.templateSrv.replace(column.style.linkTooltip, scopedVars);
|
||||||
const cellTarget = column.style.linkTargetBlank ? '_blank' : '';
|
const cellTarget = column.style.linkTargetBlank ? '_blank' : '';
|
||||||
|
|
||||||
cellClasses.push('table-panel-cell-link');
|
cellClasses.push('table-panel-cell-link');
|
||||||
|
|
||||||
columnHtml += `
|
columnHtml += `
|
||||||
<a href="${cellLink}" target="${cellTarget}" data-link-tooltip data-original-title="${cellLinkTooltip}" data-placement="right"${cellStyle}>
|
<a href="${sanitizedCellLink}" target="${cellTarget}" data-link-tooltip data-original-title="${cellLinkTooltip}" data-placement="right"${cellStyle}>
|
||||||
${value}
|
${value}
|
||||||
</a>
|
</a>
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user