- opening balance: "person 2 owes person 1" was stored the wrong way round - retour param: reject backslash/control chars (open redirect) - backup: pipefail + check dump completeness, failed dumps no longer logged OK - deleting a recurring occurrence marks it skipped so sync does not recreate it - editing a charge regenerates future occurrences of incomes allocated to it - settlements (incl. opening balance) listed in settings and deletable Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
773 B
TypeScript
20 lines
773 B
TypeScript
// Antislash et caractères de contrôle : les navigateurs les normalisent en « // » (sortie du site).
|
|
const UNSAFE = /[\\\u0000-\u001f\u007f]/;
|
|
|
|
function decoded(value: string): string {
|
|
try {
|
|
return decodeURIComponent(value);
|
|
} catch {
|
|
return value;
|
|
}
|
|
}
|
|
|
|
/** Chemin de retour interne uniquement (anti-redirection ouverte), sinon `fallback`. */
|
|
export function safeReturn(value: string | undefined | null, fallback: string): string {
|
|
if (!value || !value.startsWith("/") || value.startsWith("//")) return fallback;
|
|
if (UNSAFE.test(value) || UNSAFE.test(decoded(value))) return fallback;
|
|
const url = new URL(value, "http://local.invalid");
|
|
if (url.origin !== "http://local.invalid") return fallback;
|
|
return url.pathname + url.search + url.hash;
|
|
}
|