feat(auth): enforce length limits for name and password during registration

feat(comments): add content length validation for comments and annotations

feat(guest-gate): restrict guest name length and update localStorage handling

feat(share-link-unlock): set maxLength for password input field
This commit is contained in:
Yusuf İpek
2026-04-10 20:28:55 +03:00
parent d1ffc4c4db
commit 03bfd565e8
4 changed files with 21 additions and 7 deletions
@@ -252,6 +252,17 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
return apiErrors.badRequest('Either content, a voice recording, an image attachment, or an annotation is required');
}
// Length limits to prevent DB bloat and DoS on export/notification paths
if (content !== undefined && content !== null && String(content).length > 10_000) {
return apiErrors.badRequest('Comment content must be 10,000 characters or fewer');
}
if (guestName !== undefined && guestName !== null && String(guestName).length > 100) {
return apiErrors.badRequest('Guest name must be 100 characters or fewer');
}
if (annotationData !== undefined && annotationData !== null && JSON.stringify(annotationData).length > 50_000) {
return apiErrors.badRequest('Annotation data is too large');
}
// If replying, verify parent exists in same version
if (parentId) {
const parent = await db.comment.findFirst({