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:
WolfandClaude Sonnet committed 2026-09-29 15:24:54 +02:00
1 parent 4fb9e801f5
commit 5dfaa393be
6 files changed
+40 -20

No files matched your search

+1 -3
View File
@@ -47,7 +47,7 @@
(function () {
"use strict";
const { api, esc, debounce, companies, loadCompanies, affinityControl, judgeButtons,
const { api, esc, debounce, safeUrl, companies, loadCompanies, affinityControl, judgeButtons,
loadTracked } = window;
const $ = (sel, root = document) => root.querySelector(sel);
@@ -110,8 +110,6 @@
feedError: false, // the feed's own fetch failed; the empty state offers a retry
};
const safeUrl = (u) => (/^https?:\/\//i.test(u || "") ? u : "");
function ago(iso) {
const mins = (Date.now() - new Date(iso)) / 60000;
if (!Number.isFinite(mins)) return "";