Guard every feed-, board-, discovery- or user-supplied link with safeUrl
roles.js already checked a role's original_url is http(s) before putting it in an href, so a board that wrote something other than a URL could not make the reader navigate to it; sources.js (a search sample's row.url), companies.js (careers_url) and applications.js (application.url) put the same kind of outside data straight into a link unchecked. safeUrl moves to app.js, beside the app's other shared helpers, and is exported the same way; a link whose safeUrl comes back empty is now left out of the page (plain text) instead of getting an href of "". Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
This commit is contained in:
1 parent
4fb9e801f5
commit
5dfaa393be
6 files changed
+40
-20
No files matched your search
@@ -21,7 +21,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const { api, count, debounce, companies, loadCompanies, affinityControl } = window;
|
||||
const { api, count, debounce, safeUrl, companies, loadCompanies, affinityControl } = window;
|
||||
const $ = (sel, root = document) => root.querySelector(sel);
|
||||
|
||||
/** @type {object[]} the search agents, by id */
|
||||
@@ -76,9 +76,10 @@
|
||||
// found where this company posts its roles.
|
||||
sub.append("board not found");
|
||||
}
|
||||
if (company.careers_url && !company.board) {
|
||||
const careersUrl = safeUrl(company.careers_url);
|
||||
if (careersUrl && !company.board) {
|
||||
const link = document.createElement("a");
|
||||
link.href = company.careers_url;
|
||||
link.href = careersUrl;
|
||||
link.target = "_blank";
|
||||
link.rel = "noopener";
|
||||
link.textContent = "careers page";
|
||||
|
||||
Reference in new issue
Block a user