PostEmbed の安全性強化(#130) #263

マージ済み
みてるぞ が 3 個のコミットを feature/130 から main へマージ 2026-02-13 12:39:52 +09:00
コミット e7dac653d5 の変更だけを表示してゐます - すべてのコミットを表示
+7
ファイルの表示
@@ -21,23 +21,30 @@ export default (({ post }: Props) => {
const mVideoId = url.pathname.match (/(?<=\/watch\/)[a-zA-Z0-9]+?(?=\/|$)/) const mVideoId = url.pathname.match (/(?<=\/watch\/)[a-zA-Z0-9]+?(?=\/|$)/)
if (!(mVideoId)) if (!(mVideoId))
break break
const [videoId] = mVideoId const [videoId] = mVideoId
return <NicoViewer id={videoId} width={640} height={360}/> return <NicoViewer id={videoId} width={640} height={360}/>
} }
case 'twitter.com': case 'twitter.com':
case 'x.com': case 'x.com':
{
const mUserId = url.pathname.match (/(?<=\/)[^\/]+?(?=\/|$|\?)/) const mUserId = url.pathname.match (/(?<=\/)[^\/]+?(?=\/|$|\?)/)
const mStatusId = url.pathname.match (/(?<=\/status\/)\d+?(?=\/|$|\?)/) const mStatusId = url.pathname.match (/(?<=\/status\/)\d+?(?=\/|$|\?)/)
if (!(mUserId) || !(mStatusId)) if (!(mUserId) || !(mStatusId))
break break
const [userId] = mUserId const [userId] = mUserId
const [statusId] = mStatusId const [statusId] = mStatusId
return <TwitterEmbed userId={userId} statusId={statusId}/> return <TwitterEmbed userId={userId} statusId={statusId}/>
}
case 'youtube.com': case 'youtube.com':
{ {
const videoId = url.searchParams.get ('v') const videoId = url.searchParams.get ('v')
if (!(videoId)) if (!(videoId))
break break
return ( return (
<YoutubeEmbed videoId={videoId} opts={{ playerVars: { <YoutubeEmbed videoId={videoId} opts={{ playerVars: {
playsinline: 1, playsinline: 1,