mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 10:15:43 +03:00
remove unused 'body' var; use a finally
to clean up the temporary textfilter
This commit is contained in:
parent
92435c0865
commit
1c30640a92
1 changed files with 21 additions and 17 deletions
|
@ -136,12 +136,13 @@ module.exports = {
|
||||||
|
|
||||||
var isHtml = (content.format === "org.matrix.custom.html");
|
var isHtml = (content.format === "org.matrix.custom.html");
|
||||||
|
|
||||||
var safeBody, body;
|
var safeBody;
|
||||||
if (isHtml) {
|
if (isHtml) {
|
||||||
// XXX: We sanitize the HTML whilst also highlighting its text nodes, to avoid accidentally trying
|
// XXX: We sanitize the HTML whilst also highlighting its text nodes, to avoid accidentally trying
|
||||||
// to highlight HTML tags themselves. However, this does mean that we don't highlight textnodes which
|
// to highlight HTML tags themselves. However, this does mean that we don't highlight textnodes which
|
||||||
// are interrupted by HTML tags (not that we did before) - e.g. foo<span/>bar won't get highlighted
|
// are interrupted by HTML tags (not that we did before) - e.g. foo<span/>bar won't get highlighted
|
||||||
// by an attempt to search for 'foobar'. Then again, the search query probably wouldn't work either
|
// by an attempt to search for 'foobar'. Then again, the search query probably wouldn't work either
|
||||||
|
try {
|
||||||
if (highlights && highlights.length > 0) {
|
if (highlights && highlights.length > 0) {
|
||||||
var highlighter = new Highlighter(isHtml, "mx_EventTile_searchHighlight", opts.onHighlightClick);
|
var highlighter = new Highlighter(isHtml, "mx_EventTile_searchHighlight", opts.onHighlightClick);
|
||||||
var safeHighlights = highlights.map(function(highlight) {
|
var safeHighlights = highlights.map(function(highlight) {
|
||||||
|
@ -158,7 +159,10 @@ module.exports = {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
safeBody = sanitizeHtml(content.formatted_body, sanitizeHtmlParams);
|
safeBody = sanitizeHtml(content.formatted_body, sanitizeHtmlParams);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
delete sanitizeHtmlParams.textFilter;
|
delete sanitizeHtmlParams.textFilter;
|
||||||
|
}
|
||||||
return <span className="markdown-body" dangerouslySetInnerHTML={{ __html: safeBody }} />;
|
return <span className="markdown-body" dangerouslySetInnerHTML={{ __html: safeBody }} />;
|
||||||
} else {
|
} else {
|
||||||
safeBody = content.body;
|
safeBody = content.body;
|
||||||
|
|
Loading…
Reference in a new issue