Skip to content

Commit 9f4e5d3

Browse files
committed
search: be careful when displaying data from the search index
Just like the search term, which should be handled as plain text without mistaking it as HTML, the data coming from the search index should be treated likewise. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent ee6a598 commit 9f4e5d3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

assets/js/application.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,11 @@ var Search = {
328328
if (!i || typeof results.results[i - 1].data === 'object') categorizeResult(i);
329329
result.data.meta.title = result.data.meta.title.replace(/^Git - (.*) Documentation$/, "$1")
330330
result.data.url = result.data.url.replace(/\.html$/, '')
331-
result.li.html(`<a href = "${result.data.url}">${result.data.meta.title}</a>`);
331+
// Build result item safely (no HTML parsing).
332+
const a = $("<a>");
333+
a.attr("href", result.data.url);
334+
a.text(result.data.meta.title);
335+
result.li.empty().append(a);
332336
})(displayCount).catch((err) => {
333337
console.log(err);
334338
result.li.html(`<i>Error loading result</i>`);

0 commit comments

Comments
 (0)