Skip to content
Snippets Groups Projects
Commit 1c30640a authored by Matthew Hodgson's avatar Matthew Hodgson
Browse files

remove unused 'body' var; use a `finally` to clean up the temporary textfilter

parent 92435c08
No related branches found
No related tags found
No related merge requests found
...@@ -136,12 +136,13 @@ module.exports = { ...@@ -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 = { ...@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment