Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and Recore uses semantic versioning.

## [Unreleased]

### Fixed

- The website's policy picker builds its sentence from text nodes instead of
markup, so a policy name read from the page is always shown as text and can
never run as HTML (CodeQL `js/xss-through-dom`). The documentation search
also escapes quotes in the result links it writes.

### Added

- Recore is archived on Zenodo. The README carries the DOI badge and both DOIs
Expand Down
21 changes: 16 additions & 5 deletions docs/assets/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,20 @@
b.setAttribute("aria-pressed", b.getAttribute("data-policy") === policy ? "true" : "false");
});
if (summary) {
summary.innerHTML =
"With <code>" + policy + "</code>, <b>" + putBack + " of " + total + "</b> go into the corrected matrix. " +
"The other " + (total - putBack) + " stay in the states file and <code>orthology_evidence.tsv</code>, with the reason.";
// Built from nodes, not markup: the policy name is read from the
// page, and it goes in as text.
var code = function (text) {
var el = document.createElement("code");
el.textContent = text;
return el;
};
var count = document.createElement("b");
count.textContent = putBack + " of " + total;
summary.textContent = "";
summary.append(
"With ", code(policy), ", ", count, " go into the corrected matrix. The other " + (total - putBack) +
" stay in the states file and ", code("orthology_evidence.tsv"), ", with the reason."
);
}
}
buttons.forEach(function (b) {
Expand Down Expand Up @@ -599,7 +610,7 @@
var active = -1;

function escapeHtml(text) {
return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
}

// Words match where a word starts, so "min" finds --min-prevalence and
Expand Down Expand Up @@ -669,7 +680,7 @@
var e = hit.entry;
var title = e.section ? e.page + " \u203a " + e.section : e.page;
return (
'<a href="' + root + e.url + '"><b>' + highlight(title, words) + "</b><small>" +
'<a href="' + escapeHtml(root + e.url) + '"><b>' + highlight(title, words) + "</b><small>" +
highlight(snippet(e.text, words[0]), words) + "</small></a>"
);
})
Expand Down
Loading