Skip to content

Commit

Permalink
fix(search-pad): prevent HTML injection
Browse files Browse the repository at this point in the history
Given the apprioritate title and search text HTML injection was
possible until now.
  • Loading branch information
nikku committed Jun 12, 2019
1 parent b724111 commit 777fa06
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/features/search-pad/SearchPad.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {
getBBox as getBoundingBox
} from '../../util/Elements';

import {
escapeHTML
} from '../../util/EscapeUtil';

/**
* Provides searching infrastructure
Expand Down Expand Up @@ -507,9 +510,9 @@ function createHtmlText(tokens) {

tokens.forEach(function(t) {
if (t.matched) {
htmlText += '<strong class="' + SearchPad.RESULT_HIGHLIGHT_CLASS + '">' + t.matched + '</strong>';
htmlText += '<strong class="' + SearchPad.RESULT_HIGHLIGHT_CLASS + '">' + escapeHTML(t.matched) + '</strong>';
} else {
htmlText += t.normal;
htmlText += escapeHTML(t.normal);
}
});

Expand Down

0 comments on commit 777fa06

Please sign in to comment.