Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ import {
t,
tn,
useTheme,
isProbablyHTML,
removeHTMLTags,
SupersetTheme,
} from '@superset-ui/core';
import {
Expand Down Expand Up @@ -251,6 +253,13 @@ function SelectPageSize({
const getNoResultsMessage = (filter: string) =>
filter ? t('No matching records found') : t('No records found');

const sanitizeHtmlValue = (value: DataRecordValue): DataRecordValue => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't use the sanitizeHtml from the utils? Guessing this is different? does this function belongs in the utils or is it component-specific?

@amaannawab923 amaannawab923 Aug 14, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is different , its about extracting value from Html Tag ->
Input :
< /a href="https://www.google.com/search?q=United Kingdom">United Kingdom</a>"

Expected Output:
United Kingdom

Sanitise Html function would just sanitise that html to remove malicious code

For now , i guess this is component specific , because it will only come to use here in Table

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the function name is causing confusion with html sanitisation , should probably rename it to , ExtractTextFromHtml

if (typeof value === 'string' && isProbablyHTML(value)) {
return removeHTMLTags(value);
}
Comment thread
amaannawab923 marked this conversation as resolved.
Outdated
return value;
};

export default function TableChart<D extends DataRecord = DataRecord>(
props: TableChartTransformedProps<D> & {
sticky?: DataTableProps<D>['sticky'];
Expand Down Expand Up @@ -478,7 +487,9 @@ export default function TableChart<D extends DataRecord = DataRecord>(
const drillToDetailFilters: BinaryQueryObjectFilterClause[] = [];
filteredColumnsMeta.forEach(col => {
if (!col.isMetric) {
const dataRecordValue = value[col.key];
let dataRecordValue = value[col.key];
dataRecordValue = sanitizeHtmlValue(dataRecordValue);

drillToDetailFilters.push({
col: col.key,
op: '==',
Expand All @@ -499,7 +510,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
{
col: cellPoint.key,
op: '==',
val: cellPoint.value as string | number | boolean,
val: sanitizeHtmlValue(cellPoint.value),
},
],
groupbyFieldName: 'groupby',
Expand Down
Loading