<commit_before>import React from "react";
import PropTypes from "prop-types";
import Modal from "react-modal";
import I18n from "i18n-js";
import {isEmpty, stop} from "../utils/utils";
import "react-mde/lib/styles/css/react-mde-all.css";
import DOMPurify from 'dompurify';
import * as Showdown from "showdown";

const converter = new Showdown.Converter({
    tables: true,
    simplifiedAutoLink: true,
    strikethrough: true,
    tasklists: true
});

const sanitizeHtml = html => {
    if (isEmpty(html)) {
        return "";
    }
    html = DOMPurify.sanitize(html);
    return html.replace(/<a /g, "<a target='_blank'")
};

export default function PostInviteDialog({isOpen = false, team, markdown, cancel}) {
    return (
        <Modal
            isOpen={isOpen}
            onRequestClose={cancel}
            contentLabel={I18n.t("post_invite_dialog.title", {name: team.name})}
            className="post-invite-dialog-content"
            overlayClassName="post-invite-dialog-overlay"
            closeTimeoutMS={250}
            ariaHideApp={false}>
            <section className="post-invite-header">
                {I18n.t("post_invite_dialog.title", {name: team.name})}
            </section>
            <div className="post-invite-content mde-preview">
                <div className="mde-preview-content">
                    <p dangerouslySetInnerHTML={{
                        __html: sanitizeHtml(converter.makeHtml(markdown))
                    }}/>
                </div>
            </div>
            <section className="post-invite-buttons">
                <a className="button blue" onClick={e => {
                    stop(e);
                    cancel();
                }}>
                    {I18n.t("post_invite_dialog.close")}
                </a>
            </section>
        </Modal><commit_msg>Do not open in new tab<commit_after>import React from "react";
import PropTypes from "prop-types";
import Modal from "react-modal";
import I18n from "i18n-js";
import {isEmpty, stop} from "../utils/utils";
import "react-mde/lib/styles/css/react-mde-all.css";
import DOMPurify from 'dompurify';
import * as Showdown from "showdown";

const converter = new Showdown.Converter({
    tables: true,
    simplifiedAutoLink: true,
    strikethrough: true,
    tasklists: true
});

const sanitizeHtml = html => {
    if (isEmpty(html)) {
        return "";
    }
    return DOMPurify.sanitize(html);
};

export default function PostInviteDialog({isOpen = false, team, markdown, cancel}) {
    return (
        <Modal
            isOpen={isOpen}
            onRequestClose={cancel}
            contentLabel={I18n.t("post_invite_dialog.title", {name: team.name})}
            className="post-invite-dialog-content"
            overlayClassName="post-invite-dialog-overlay"
            closeTimeoutMS={250}
            ariaHideApp={false}>
            <section className="post-invite-header">
                {I18n.t("post_invite_dialog.title", {name: team.name})}
            </section>
            <div className="post-invite-content mde-preview">
                <div className="mde-preview-content">
                    <p dangerouslySetInnerHTML={{
                        __html: sanitizeHtml(converter.makeHtml(markdown))
                    }}/>
                </div>
            </div>
            <section className="post-invite-buttons">
                <a className="button blue" onClick={e => {
                    stop(e);
                    cancel();
                }}>
                    {I18n.t("post_invite_dialog.close")}
                </a>
            </section>
        </Modal>
{'fraction_non_alphanumeric': 0.12992017616295073, 'fraction_numerical': 0.007156619873382879, 'mean_word_length': 1.9860312243221034, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5010131', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1017, 'n_words': 209}