You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2022/12/14 11:42:46 UTC
[superset] branch chore/handlebars-safemarkdown-config created (now 07a550c045)
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a change to branch chore/handlebars-safemarkdown-config
in repository https://gitbox.apache.org/repos/asf/superset.git
at 07a550c045 Force configuration for SafeMarkdown
This branch includes the following new commits:
new 07a550c045 Force configuration for SafeMarkdown
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[superset] 01/01: Force configuration for SafeMarkdown
Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a commit to branch chore/handlebars-safemarkdown-config
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 07a550c0455d31540d079ce4d01736b92e8cf71d
Author: geido <di...@gmail.com>
AuthorDate: Wed Dec 14 12:42:28 2022 +0100
Force configuration for SafeMarkdown
---
.../superset-ui-core/src/components/SafeMarkdown.tsx | 15 ++++++++-------
.../src/dashboard/components/gridComponents/Markdown.jsx | 8 --------
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx b/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx
index 4db48d4265..7ab7e71348 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx
+++ b/superset-frontend/packages/superset-ui-core/src/components/SafeMarkdown.tsx
@@ -25,15 +25,16 @@ import { FeatureFlag, isFeatureEnabled } from '../utils';
interface SafeMarkdownProps {
source: string;
- htmlSanitization?: boolean;
- htmlSchemaOverrides?: typeof defaultSchema;
}
-function SafeMarkdown({
- source,
- htmlSanitization = true,
- htmlSchemaOverrides = {},
-}: SafeMarkdownProps) {
+function SafeMarkdown({ source }: SafeMarkdownProps) {
+ const appContainer = document.getElementById('app');
+ const { common } = JSON.parse(
+ appContainer?.getAttribute('data-bootstrap') || '{}',
+ );
+ const htmlSanitization: boolean = common?.conf?.HTML_SANITIZATION ?? true;
+ const htmlSchemaOverrides: typeof defaultSchema =
+ common?.conf?.HTML_SANITIZATION_SCHEMA_EXTENSIONS || {};
const displayHtml = isFeatureEnabled(FeatureFlag.DISPLAY_MARKDOWN_HTML);
const escapeHtml = isFeatureEnabled(FeatureFlag.ESCAPE_MARKDOWN_HTML);
diff --git a/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx b/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx
index d4a4f7790b..79fccfadc9 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/Markdown.jsx
@@ -65,10 +65,6 @@ const propTypes = {
deleteComponent: PropTypes.func.isRequired,
handleComponentDrop: PropTypes.func.isRequired,
updateComponents: PropTypes.func.isRequired,
-
- // HTML sanitization
- htmlSanitization: PropTypes.bool,
- htmlSchemaOverrides: PropTypes.object,
};
const defaultProps = {};
@@ -269,8 +265,6 @@ class Markdown extends React.PureComponent {
? MARKDOWN_ERROR_MESSAGE
: this.state.markdownSource || MARKDOWN_PLACE_HOLDER
}
- htmlSanitization={this.props.htmlSanitization}
- htmlSchemaOverrides={this.props.htmlSchemaOverrides}
/>
);
}
@@ -379,8 +373,6 @@ function mapStateToProps(state) {
return {
undoLength: state.dashboardLayout.past.length,
redoLength: state.dashboardLayout.future.length,
- htmlSanitization: state.common.conf.HTML_SANITIZATION,
- htmlSchemaOverrides: state.common.conf.HTML_SANITIZATION_SCHEMA_EXTENSIONS,
};
}
export default connect(mapStateToProps)(Markdown);