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