diff --git a/frontend/src/components/MediaViewer.jsx b/frontend/src/components/MediaViewer.jsx index 3a17b39..d666fc6 100644 --- a/frontend/src/components/MediaViewer.jsx +++ b/frontend/src/components/MediaViewer.jsx @@ -135,15 +135,17 @@ const MediaViewer = ({ media, person, onClose }) => { // Extract YouTube video ID and build embed URL const watchMatch = mediaUrl.match(/[?&]v=([^&]+)/) const shortMatch = mediaUrl.match(/youtu\.be\/([^/?]+)/) - const videoId = (watchMatch?.[1] || shortMatch?.[1] || '').split('?')[0] - if (!videoId) { + const videoId = (watchMatch?.[1] || shortMatch?.[1] || '').split(/[?#]/)[0] + // Un identifiant YouTube fait 11 caractères : tout le reste est refusé plutôt qu'intégré + if (!/^[A-Za-z0-9_-]{11}$/.test(videoId)) { return (
{t('Lien YouTube invalide')}
) } - const embedUrl = `https://www.youtube.com/embed/${videoId}` + // youtube-nocookie : pas de cookie YouTube tant que la vidéo n'est pas lancée + const embedUrl = `https://www.youtube-nocookie.com/embed/${videoId}` return (