mistercrunch commented on code in PR #33791:
URL: https://github.com/apache/superset/pull/33791#discussion_r2271161993
##########
superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx:
##########
@@ -243,6 +243,24 @@ function SelectPageSize({
const getNoResultsMessage = (filter: string) =>
filter ? t('No matching records found') : t('No records found');
+const isHtml = (value: any): boolean => {
Review Comment:
comment crafted with Claude ->
---
Hi @amaannawab923, thanks for working on this fix!
For handling HTML content in table cells, we already have comprehensive
HTML utilities available in the codebase that should be used:
📍 HTML Utilities Location: @superset-ui/core/src/utils/html
Key functions available:
- removeHTMLTags(str) - Strips all HTML tags from a string (useful for
getting plain text for context menu operations)
- sanitizeHtml(htmlString) - Safely sanitizes HTML content using XSS
filtering
- isProbablyHTML(text) - Detects if a string contains valid HTML
- safeHtmlSpan(possiblyHtmlString) - Returns a safe React component for
rendering HTML
The table chart already uses these utilities in
superset-frontend/plugins/plugin-chart-table/src/utils/formatValue.ts:54 for
sanitizing HTML content when allowRenderHtml is enabled.
For the context menu issue with HTML <a> tags, you might want to use
removeHTMLTags() to extract the plain text value for drill-down operations.
This is already being done in the drill detail menu items (see
DrillDetailMenuItems.tsx:93).
Example usage:
import { removeHTMLTags } from '@superset-ui/core';
// When handling context menu for HTML cells
const plainTextValue = removeHTMLTags(htmlCellValue);
This approach ensures consistency with how HTML is handled throughout the
codebase and maintains proper security sanitization.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]