Commit 727c550003
Unsigned
Layout: unified · split
src/dashboard.ts +4 −1
| @@ -47,7 +47,10 @@ export interface DashboardData { | |||
| 47 | lastPolledAt: string | null; | 47 | lastPolledAt: string | null; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | function esc(value: unknown): string { | 50 | // Deliberately narrower than `unknown`: an object reaching here would render |
| 51 | // as "[object Object]" in an evidence table, which is worse than failing. | ||
| 52 | // Keeping the parameter to primitives makes that a compile error instead. | ||
| 53 | function esc(value: string | number | null | undefined): string { | ||
| 51 | return String(value ?? "").replace(/[&<>"']/g, (c) => { | 54 | return String(value ?? "").replace(/[&<>"']/g, (c) => { |
| 52 | switch (c) { | 55 | switch (c) { |
| 53 | case "&": return "&"; | 56 | case "&": return "&"; |