|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
|
|
|
|
|
import { useTranslation } from 'next-i18next';
|
|
import { useTranslation } from 'next-i18next';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
+import { defaultSchema as sanitizeDefaultSchema } from 'rehype-sanitize';
|
|
|
|
|
|
|
|
import AdminMarkDownContainer from '~/client/services/AdminMarkDownContainer';
|
|
import AdminMarkDownContainer from '~/client/services/AdminMarkDownContainer';
|
|
|
-import { tags, attrs } from '~/services/xss/recommended-whitelist';
|
|
|
|
|
|
|
|
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
|
|
|
|
|
@@ -16,18 +16,21 @@ class WhiteListInput extends React.Component {
|
|
|
this.tagWhiteList = React.createRef();
|
|
this.tagWhiteList = React.createRef();
|
|
|
this.attrWhiteList = React.createRef();
|
|
this.attrWhiteList = React.createRef();
|
|
|
|
|
|
|
|
|
|
+ this.tags = sanitizeDefaultSchema.tagNames;
|
|
|
|
|
+ this.attrs = JSON.stringify(sanitizeDefaultSchema.attributes);
|
|
|
|
|
+
|
|
|
this.onClickRecommendTagButton = this.onClickRecommendTagButton.bind(this);
|
|
this.onClickRecommendTagButton = this.onClickRecommendTagButton.bind(this);
|
|
|
this.onClickRecommendAttrButton = this.onClickRecommendAttrButton.bind(this);
|
|
this.onClickRecommendAttrButton = this.onClickRecommendAttrButton.bind(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onClickRecommendTagButton() {
|
|
onClickRecommendTagButton() {
|
|
|
- this.tagWhiteList.current.value = tags;
|
|
|
|
|
- this.props.adminMarkDownContainer.setState({ tagWhiteList: tags });
|
|
|
|
|
|
|
+ // this.tagWhiteList.current.value = this.tags;
|
|
|
|
|
+ // this.props.adminMarkDownContainer.setState({ tagWhiteList: this.tags });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onClickRecommendAttrButton() {
|
|
onClickRecommendAttrButton() {
|
|
|
- this.attrWhiteList.current.value = attrs;
|
|
|
|
|
- this.props.adminMarkDownContainer.setState({ attrWhiteList: attrs });
|
|
|
|
|
|
|
+ // this.attrWhiteList.current.value = this.attrs;
|
|
|
|
|
+ // this.props.adminMarkDownContainer.setState({ attrWhiteList: this.attrs });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
@@ -38,11 +41,12 @@ class WhiteListInput extends React.Component {
|
|
|
<div className="mt-4">
|
|
<div className="mt-4">
|
|
|
<div className="d-flex justify-content-between">
|
|
<div className="d-flex justify-content-between">
|
|
|
{t('markdown_settings.xss_options.tag_names')}
|
|
{t('markdown_settings.xss_options.tag_names')}
|
|
|
- <p id="btn-import-tags" className="btn btn-sm btn-primary mb-0" onClick={this.onClickRecommendTagButton}>
|
|
|
|
|
|
|
+ <p id="btn-import-tags" className="btn btn-sm btn-primary mb-0 disabled" onClick={this.onClickRecommendTagButton}>
|
|
|
{t('markdown_settings.xss_options.import_recommended', { target: 'Tags' })}
|
|
{t('markdown_settings.xss_options.import_recommended', { target: 'Tags' })}
|
|
|
</p>
|
|
</p>
|
|
|
</div>
|
|
</div>
|
|
|
<textarea
|
|
<textarea
|
|
|
|
|
+ disabled
|
|
|
className="form-control xss-list"
|
|
className="form-control xss-list"
|
|
|
name="recommendedTags"
|
|
name="recommendedTags"
|
|
|
rows="6"
|
|
rows="6"
|
|
@@ -55,11 +59,12 @@ class WhiteListInput extends React.Component {
|
|
|
<div className="mt-4">
|
|
<div className="mt-4">
|
|
|
<div className="d-flex justify-content-between">
|
|
<div className="d-flex justify-content-between">
|
|
|
{t('markdown_settings.xss_options.tag_attributes')}
|
|
{t('markdown_settings.xss_options.tag_attributes')}
|
|
|
- <p id="btn-import-tags" className="btn btn-sm btn-primary mb-0" onClick={this.onClickRecommendAttrButton}>
|
|
|
|
|
|
|
+ <p id="btn-import-tags" className="btn btn-sm btn-primary mb-0 disabled" onClick={this.onClickRecommendAttrButton}>
|
|
|
{t('markdown_settings.xss_options.import_recommended', { target: 'Attrs' })}
|
|
{t('markdown_settings.xss_options.import_recommended', { target: 'Attrs' })}
|
|
|
</p>
|
|
</p>
|
|
|
</div>
|
|
</div>
|
|
|
<textarea
|
|
<textarea
|
|
|
|
|
+ disabled
|
|
|
className="form-control xss-list"
|
|
className="form-control xss-list"
|
|
|
name="recommendedAttrs"
|
|
name="recommendedAttrs"
|
|
|
rows="6"
|
|
rows="6"
|