@@ -7,15 +7,13 @@ describe('getEmbedInfo', () => {
77 expect ( getEmbedInfo ( 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' ) ) . toEqual ( expected )
88 expect ( getEmbedInfo ( 'https://youtu.be/dQw4w9WgXcQ' ) ) . toEqual ( expected )
99 expect ( getEmbedInfo ( 'https://www.youtube.com/embed/dQw4w9WgXcQ' ) ) . toEqual ( expected )
10- // Extra query params around v=, a youtu.be tracking param, a trailing slash,
11- // and an embed query string all still resolve to the same embed.
1210 expect ( getEmbedInfo ( 'https://www.youtube.com/watch?list=RD&v=dQw4w9WgXcQ&t=5' ) ) . toEqual (
1311 expected
1412 )
1513 expect ( getEmbedInfo ( 'https://youtu.be/dQw4w9WgXcQ?si=abc' ) ) . toEqual ( expected )
1614 expect ( getEmbedInfo ( 'https://youtu.be/dQw4w9WgXcQ/' ) ) . toEqual ( expected )
1715 expect ( getEmbedInfo ( 'https://www.youtube.com/embed/dQw4w9WgXcQ?rel=0' ) ) . toEqual ( expected )
18- // A non-11-char id is not a valid YouTube video and does not embed.
16+ expect ( getEmbedInfo ( 'https://www.youtube.com/ embed/dQw4w9WgXcQ?v=notAnId' ) ) . toEqual ( expected )
1917 expect ( getEmbedInfo ( 'https://www.youtube.com/watch?v=short' ) ) . toBeNull ( )
2018 } )
2119
@@ -63,13 +61,10 @@ describe('getEmbedInfo', () => {
6361 } )
6462
6563 it ( 'only embeds when the parsed host belongs to the provider' , ( ) => {
66- // A provider domain in the path or as a subdomain prefix of an attacker host
67- // must not be treated as that provider.
6864 expect ( getEmbedInfo ( 'https://evil.com/youtube.com/watch?v=dQw4w9WgXcQ' ) ) . toBeNull ( )
6965 expect ( getEmbedInfo ( 'https://youtube.com.evil.com/watch?v=dQw4w9WgXcQ' ) ) . toBeNull ( )
7066 expect ( getEmbedInfo ( 'https://evil.com/open.spotify.com/track/abc123' ) ) . toBeNull ( )
7167 expect ( getEmbedInfo ( 'https://vimeo.com.evil.com/123456' ) ) . toBeNull ( )
72- // Legitimate subdomains of a provider still embed.
7368 expect ( getEmbedInfo ( 'https://m.youtube.com/watch?v=dQw4w9WgXcQ' ) ) . toEqual ( {
7469 url : 'https://www.youtube.com/embed/dQw4w9WgXcQ' ,
7570 type : 'iframe' ,
@@ -96,8 +91,6 @@ describe('getEmbedInfo', () => {
9691 } )
9792
9893 it ( 'does not apply the Dropbox direct-link rewrite to look-alike hosts' , ( ) => {
99- // Look-alike hosts fall through to the generic video handler with their
100- // original (untrusted) host intact — never rewritten as if trusted Dropbox.
10194 expect ( getEmbedInfo ( 'https://dropbox.com.evil.com/clip.mp4' ) ?. url ) . not . toContain (
10295 'dropboxusercontent.com'
10396 )
0 commit comments