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
@@ -9,7 +9,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const { api, count, cell, companies, loadCompanies } = window;
|
||||
const { api, count, cell, safeUrl, companies, loadCompanies } = window;
|
||||
const $ = (sel, root = document) => root.querySelector(sel);
|
||||
|
||||
// `ROLEDESK_STATUSES` is set by applications.html from the same `STATUSES`
|
||||
@@ -41,13 +41,14 @@
|
||||
body.replaceChildren();
|
||||
for (const application of applications) {
|
||||
const tr = document.createElement("tr");
|
||||
if (application.role_uid || application.url) {
|
||||
const externalUrl = safeUrl(application.url);
|
||||
if (application.role_uid || externalUrl) {
|
||||
const link = document.createElement("a");
|
||||
link.textContent = application.role_title || "(untitled)";
|
||||
if (application.role_uid) {
|
||||
link.href = `/roles/${encodeURIComponent(application.role_uid)}`;
|
||||
} else {
|
||||
link.href = application.url;
|
||||
link.href = externalUrl;
|
||||
link.target = "_blank";
|
||||
link.rel = "noopener";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user