feat(validation): implement validateAnnotationStrokes function for safe annotation data handling

feat(rate-limit): add TRUSTED_PROXY_MODE for configurable proxy header trust
feat(comments): validate annotation data structure in comment routes and components
This commit is contained in:
Yusuf İpek
2026-04-10 20:38:22 +03:00
parent 03bfd565e8
commit 439e74d037
8 changed files with 134 additions and 29 deletions
@@ -11,6 +11,7 @@ import type {
PlayerAdapter,
Version,
} from '@/components/video-page/types';
import { validateAnnotationStrokes } from '@/lib/validation';
interface UseVideoPlayerParams {
activeVersion: Version | undefined;
@@ -765,8 +766,9 @@ export function useVideoPlayer({
}
if (annotation) {
try {
const strokes = JSON.parse(annotation) as AnnotationStroke[];
setViewingAnnotation(strokes);
const parsed = JSON.parse(annotation);
const safe = validateAnnotationStrokes(parsed);
setViewingAnnotation(safe as AnnotationStroke[] | null);
} catch {
setViewingAnnotation(null);
}