Skip to content

Commit

Permalink
formatMessage fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim73i committed Oct 5, 2022
1 parent d5a8f36 commit d9bf984
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { Component } from 'react';
import PropTypes from 'prop-types';
import DOMPurify from 'dompurify';
import { connect } from 'react-redux';
import classNames from 'classnames/bind';
import { injectIntl, defineMessages } from 'react-intl';
Expand Down Expand Up @@ -136,7 +137,12 @@ export class IgnoreInAAModal extends Component {
data: { items },
} = this.props;
return items.length === 1
? Parser(intl.formatMessage(messages.text, { name: items[0].name }))
? Parser(
intl.formatMessage(messages.text, {
b: (data) => DOMPurify.sanitize(`<b>${data}</b>`),
name: items[0].name,
}),
)
: intl.formatMessage(messages.textMultiple);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { Component } from 'react';
import PropTypes from 'prop-types';
import DOMPurify from 'dompurify';
import { connect } from 'react-redux';
import classNames from 'classnames/bind';
import { injectIntl, defineMessages } from 'react-intl';
Expand Down Expand Up @@ -136,7 +137,12 @@ export class IncludeInAAModal extends Component {
data: { items },
} = this.props;
return items.length === 1
? Parser(intl.formatMessage(messages.text, { name: items[0].name }))
? Parser(
intl.formatMessage(messages.text, {
b: (data) => DOMPurify.sanitize(`<b>${data}</b>`),
name: items[0].name,
}),
)
: intl.formatMessage(messages.textMultiple);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import classNames from 'classnames/bind';
import Parser from 'html-react-parser';
import DOMPurify from 'dompurify';
import { injectIntl } from 'react-intl';
import PropTypes from 'prop-types';
import styles from './blockHeader.scss';
Expand All @@ -26,7 +27,12 @@ export const BlockHeader = injectIntl(({ intl: { formatMessage }, header, hint,
<span className={cx('block-header')}>
<span className={cx('huge-message')}>{formatMessage(header)}</span>
<br />
{Parser(formatMessage(hint, hintParams))}
{Parser(
formatMessage(hint, {
b: (data) => DOMPurify.sanitize(`<b>${data}</b>`),
...hintParams,
}),
)}
</span>
));
BlockHeader.propTypes = {
Expand Down

0 comments on commit d9bf984

Please sign in to comment.