Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #722 from OpenClinica/fix/html-encoding-dn-718
Browse files Browse the repository at this point in the history
fixed: dn comments are not HTML encoded, kobotoolbox#718
  • Loading branch information
kkrumlian authored Nov 15, 2023
2 parents b9eb532 + 8e44738 commit bf5e723
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion widget/discrepancy-note/dn-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,20 @@ class Comment extends Widget {
}
}

_encodeHtml(str) {
return str.replace(
/[&<>'"]/g,
(tag) =>
({
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
"'": '&#39;',
'"': '&quot;',
}[tag])
);
}

_getHistoryRow(item, options = {}) {
const types = {
comment: '<span class="icon fa-comment-o"> </span>',
Expand Down Expand Up @@ -1638,7 +1652,9 @@ class Comment extends Widget {
types[item.type]
}</span>
<span class="or-comment-widget__content__history__row__main__comment">
<span class="or-comment-widget__content__history__row__main__comment__text">${msg}</span>
<span class="or-comment-widget__content__history__row__main__comment__text">${this._encodeHtml(
msg
)}</span>
<span class="or-comment-widget__content__history__row__main__comment__meta">
${
assignee
Expand Down

0 comments on commit bf5e723

Please sign in to comment.