More audit cleanup: shared route cache helper, url columns, tab keys

- One CACHE and json() in shape.js for the seven public route files
- A url column type: link fields (13 of them) refuse javascript:, data:
  and any other scheme on save, not only when drawn
- The chapter map's logo uses the shared Logo component
- Schedule tabs take Home and End as well as the arrows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 02:02:24 -05:00
parent 1c94ffb281
commit d1a6332a45
12 changed files with 66 additions and 75 deletions

View file

@ -35,6 +35,11 @@ export class HttpError extends Error {
const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
const CLOCK_TIME = /^([01]\d|2[0-3]):[0-5]\d$/;
// A url column may hold a full link, a site path, an anchor, a bare
// domain or a filename, but a scheme other than these is refused
// (javascript:, data:), whatever the page does with it later.
const URL_SCHEME = /^([a-z][a-z0-9+.-]*):/i;
const SAFE_SCHEMES = new Set(["http", "https", "mailto", "tel"]);
/* Not a value the caller can ever send, so it can mean "leave this
column out of the statement" without colliding with real data. */
@ -106,6 +111,15 @@ function coerceValue(column, raw, errors, prefix = "") {
if (!CLOCK_TIME.test(value)) errors[key] = "Use HH:MM, 24-hour.";
return CLOCK_TIME.test(value) ? value : null;
}
case "url": {
const value = String(raw).trim();
const scheme = URL_SCHEME.exec(value)?.[1].toLowerCase();
if (scheme && !SAFE_SCHEMES.has(scheme)) {
errors[key] = "Links must start with http://, https://, mailto: or tel:, or be a site path like /retreats.";
return null;
}
return value === "" ? null : value;
}
default: {
const value = String(raw).trim();
return value === "" ? null : value;