fix: handle base64 uploads correctly #64

Merged
naomi merged 8 commits from fix/urls into main 2026-02-20 16:53:48 -08:00
Showing only changes of commit aa6252d79f - Show all commits
+8
View File
@@ -4,6 +4,13 @@
* @author Naomi Carrigan
*/
/**
* Validates that a URL is a proper base64 data string.
*/
export function validateDataUrl(url: string): boolean {
return /^data:image\/(jpeg|png|gif|webp|svg\+xml);base64,[A-Za-z0-9+/=]+$/.test(url);
}
/**
* Validates that a URL is safe and points to an allowed protocol.
* Prevents javascript:, data:, vbscript:, and file: URLs.
@@ -83,4 +90,5 @@ export const MAX_LENGTHS = {
NOTES: 5000,
TAGS: 50, // per tag
ISBN: 50,
DATA_URL: 5 * 1024 * 1024, // 5MB in bytes (not chars)
} as const;