Prepare Portainer deployment

This commit is contained in:
Zachariah K. Sharma
2026-06-05 23:46:10 -06:00
commit e6f1c5c13f
84 changed files with 12383 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
// Centralized text-to-HTML escaping. Use everywhere user-provided strings flow
// into an HTML context (emails, raw markup, etc). React's JSX rendering escapes
// by default; this is for the non-JSX paths.
const REPLACE: Record<string, string> = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#39;",
};
export function escapeHtml(input: unknown): string {
if (input === null || input === undefined) return "";
return String(input).replace(/[&<>"']/g, (c) => REPLACE[c] ?? c);
}
// Strip everything that smells like markup. Use for places where the value
// should be plain text but might be rendered raw (mailer subject lines, etc.).
export function stripTags(input: unknown): string {
return String(input ?? "").replace(/<[^>]*>/g, "");
}
// Quick allowlist URL check — refuses anything that isn't http/https. Used on
// the redirect-after-submit setting and on webhook URLs.
export function isSafeUrl(url: string): boolean {
try {
const u = new URL(url);
return u.protocol === "http:" || u.protocol === "https:";
} catch {
return false;
}
}