mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-02-06 09:55:47 +00:00
fix(VideoEmbed): resolve lint errors
- Replace deprecated frameBorder with style={{ border: 'none' }}
- Fix unsafe regex patterns to prevent ReDoS vulnerabilities
- Anchor patterns with ^ for exact matching
- Use fixed-length YouTube video IDs (11 chars)
- Add proper terminators for URL parsing
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
0e9548e25f
commit
33f99ce4a2
@ -5,9 +5,10 @@ import { NodeViewWrapper, ReactNodeViewRenderer } from '@tiptap/react'
|
||||
import type { NodeViewProps } from '@tiptap/react'
|
||||
|
||||
// Regex patterns for video URL detection
|
||||
const YOUTUBE_REGEX = /(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/
|
||||
const YOUTUBE_SHORT_REGEX = /(?:https?:\/\/)?youtu\.be\/([a-zA-Z0-9_-]+)/
|
||||
const RUMBLE_REGEX = /(?:https?:\/\/)?rumble\.com\/embed\/([a-zA-Z0-9_-]+)/
|
||||
// Using possessive-like patterns with specific character classes to avoid ReDoS
|
||||
const YOUTUBE_REGEX = /^https?:\/\/(?:www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]{11})(?:&|$)/
|
||||
const YOUTUBE_SHORT_REGEX = /^https?:\/\/youtu\.be\/([a-zA-Z0-9_-]{11})(?:\?|$)/
|
||||
const RUMBLE_REGEX = /^https?:\/\/rumble\.com\/embed\/([a-zA-Z0-9]+)(?:\/|$)/
|
||||
|
||||
/**
|
||||
* Extracts video provider and ID from a URL
|
||||
@ -190,7 +191,7 @@ function VideoEmbedComponent({ node }: NodeViewProps) {
|
||||
allowFullScreen
|
||||
allow='fullscreen; picture-in-picture'
|
||||
className='video-embed'
|
||||
frameBorder='0'
|
||||
style={{ border: 'none' }}
|
||||
/>
|
||||
</div>
|
||||
</NodeViewWrapper>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user