fix: remplacer router.asPath mort et sécuriser les iframes tierces

This commit is contained in:
2026-07-04 11:43:49 +04:00
parent 7b9968cb82
commit 69715a1a22
+14 -6
View File
@@ -2,7 +2,7 @@
import {Box, IconButton} from '@mui/material' import {Box, IconButton} from '@mui/material'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import {useRouter} from 'next/navigation' import {usePathname} from 'next/navigation'
import { import {
Tidal, Tidal,
@@ -69,10 +69,12 @@ function RannIframe({plateforme, url, titre, isMobile}) {
{plateforme === 'Tidal' && ( {plateforme === 'Tidal' && (
<iframe <iframe
src={src} src={src}
title={titre}
allowFullScreen='allowfullscreen' allowFullScreen='allowfullscreen'
frameBorder='0' frameBorder='0'
width={`${isMobile ? '100%' : '50%'}`} width={`${isMobile ? '100%' : '50%'}`}
height='96px' height='96px'
sandbox='allow-same-origin allow-scripts allow-popups'
/> />
)} )}
@@ -90,38 +92,44 @@ function RannIframe({plateforme, url, titre, isMobile}) {
{plateforme === 'Deezer' && ( {plateforme === 'Deezer' && (
<iframe <iframe
title='deezer-widget' title={titre || 'deezer-widget'}
frameBorder='0' frameBorder='0'
src={src} src={src}
allow='encrypted-media; clipboard-write' allow='encrypted-media; clipboard-write'
allowtransparency='true' allowtransparency='true'
sandbox='allow-same-origin allow-scripts allow-popups'
/> />
)} )}
{plateforme === 'Spotify' && ( {plateforme === 'Spotify' && (
<iframe <iframe
src={src} src={src}
title={titre}
width={`${isMobile ? '100%' : '50%'}`} width={`${isMobile ? '100%' : '50%'}`}
height='80' height='80'
frameBorder='0' frameBorder='0'
allowtransparency='true' allowtransparency='true'
allow='encrypted-media' allow='encrypted-media'
sandbox='allow-same-origin allow-scripts allow-popups'
/> />
)} )}
{plateforme === 'Soundcloud' && ( {plateforme === 'Soundcloud' && (
<iframe <iframe
src={src} src={src}
title={titre}
width={`${isMobile ? '100%' : '50%'}`} width={`${isMobile ? '100%' : '50%'}`}
height='166' height='166'
scrolling='no' scrolling='no'
frameBorder='no' frameBorder='no'
sandbox='allow-same-origin allow-scripts allow-popups'
/> />
)} )}
{plateforme === 'Applemusic' && ( {plateforme === 'Applemusic' && (
<iframe <iframe
src={src} src={src}
title={titre}
width={`${isMobile ? '100%' : '50%'}`} width={`${isMobile ? '100%' : '50%'}`}
height='175' height='175'
frameBorder='0' frameBorder='0'
@@ -136,7 +144,7 @@ function RannIframe({plateforme, url, titre, isMobile}) {
function EntegreMizik({parole, isMobile}) { function EntegreMizik({parole, isMobile}) {
const [chwaMizik, meteChwaMizik] = useState(null) const [chwaMizik, meteChwaMizik] = useState(null)
const router = useRouter() const pathname = usePathname()
const {streamAudio, slug, okiMizikID, gadeEmbed, titre} = parole const {streamAudio, slug, okiMizikID, gadeEmbed, titre} = parole
const filteredKouteyAchtey = streamAudio.filter(({plateforme}) => plateforme === 'Tidal' || plateforme === 'Spotify' || plateforme === 'Deezer' || plateforme === 'Soundcloud' || plateforme === 'Applemusic') const filteredKouteyAchtey = streamAudio.filter(({plateforme}) => plateforme === 'Tidal' || plateforme === 'Spotify' || plateforme === 'Deezer' || plateforme === 'Soundcloud' || plateforme === 'Applemusic')
@@ -150,10 +158,10 @@ function EntegreMizik({parole, isMobile}) {
} }
useEffect(() => { useEffect(() => {
if (router.asPath === `/paroles/${slug}` || router.asPath === `/paroles/${slug}#${slug}`) { if (pathname === `/paroles/${slug}`) {
meteChwaMizik(null) meteChwaMizik(null)
} }
}, [router, slug]) }, [pathname, slug])
return ( return (
<Box align='center'> <Box align='center'>
@@ -162,7 +170,7 @@ function EntegreMizik({parole, isMobile}) {
key={id} key={id}
aria-label='player' aria-label='player'
size='large' size='large'
onClick={() => handleClick(plateforme, url)} onClick={() => handleClick(plateforme, url, titre)}
> >
{kouteyAchteyIcons[plateforme]} {kouteyAchteyIcons[plateforme]}
</IconButton> </IconButton>