Commit 751eb2c8 by Tobias Skarhed Committed by Torkel Ödegaard

TablePabel: Sanitize column link (#21735)

parent 089162b0
...@@ -14,6 +14,7 @@ import { ...@@ -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 { ...@@ -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>
`; `;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment