mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
Refactor markdown preview to minimize unsafe HTML. (#3842)
Fixes INS-805.
This commit is contained in:
parent
0178533e52
commit
eb67958846
@ -117,16 +117,12 @@ class MarkdownPreview extends PureComponent<Props, State> {
|
|||||||
render() {
|
render() {
|
||||||
const { className, heading } = this.props;
|
const { className, heading } = this.props;
|
||||||
const { compiled, renderError } = this.state;
|
const { compiled, renderError } = this.state;
|
||||||
const html = heading ? `<h1>${heading}</h1>\n${compiled}` : compiled;
|
|
||||||
return (
|
return (
|
||||||
<div ref={this._setPreviewRef} className={classnames('markdown-preview', className)}>
|
<div ref={this._setPreviewRef} className={classnames('markdown-preview', className)}>
|
||||||
{renderError && <p className="notice error no-margin">Failed to render: {renderError}</p>}
|
{renderError && <p className="notice error no-margin">Failed to render: {renderError}</p>}
|
||||||
<div
|
<div className="markdown-preview__content selectable">
|
||||||
className="markdown-preview__content selectable"
|
{heading ? <h1>{heading}</h1> : null}
|
||||||
dangerouslySetInnerHTML={{
|
<div dangerouslySetInnerHTML={{ __html: compiled }}></div>
|
||||||
__html: html,
|
|
||||||
}}>
|
|
||||||
{/* Set from above */}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user