Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
matrix-react-sdk
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Matrix.org
matrix-react-sdk
Commits
92435c08
Commit
92435c08
authored
Feb 10, 2016
by
Matthew Hodgson
Browse files
Options
Downloads
Patches
Plain Diff
ooops, don't forget to actually sanitize the highlights after all that
parent
d055dbe5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/HtmlUtils.js
+4
-2
4 additions, 2 deletions
src/HtmlUtils.js
with
4 additions
and
2 deletions
src/HtmlUtils.js
+
4
−
2
View file @
92435c08
...
...
@@ -144,15 +144,17 @@ module.exports = {
// by an attempt to search for 'foobar'. Then again, the search query probably wouldn't work either
if
(
highlights
&&
highlights
.
length
>
0
)
{
var
highlighter
=
new
Highlighter
(
isHtml
,
"
mx_EventTile_searchHighlight
"
,
opts
.
onHighlightClick
);
var
safeHighlights
=
highlights
.
map
(
function
(
highlight
)
{
return
sanitizeHtml
(
highlight
,
sanitizeHtmlParams
);
});
// XXX: hacky bodge to temporarily apply a textFilter to the sanitizeHtmlParams structure.
sanitizeHtmlParams
.
textFilter
=
function
(
safeText
)
{
var
html
=
highlighter
.
applyHighlights
(
safeText
,
h
ighlights
).
map
(
function
(
span
)
{
return
highlighter
.
applyHighlights
(
safeText
,
safeH
ighlights
).
map
(
function
(
span
)
{
// XXX: rather clunky conversion from the react nodes returned by applyHighlights
// (which need to be nodes for the non-html highlighting case), to convert them
// back into raw HTML given that's what sanitize-html works in terms of.
return
ReactDOMServer
.
renderToString
(
span
);
}).
join
(
''
);
return
html
;
};
}
safeBody
=
sanitizeHtml
(
content
.
formatted_body
,
sanitizeHtmlParams
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment