Embeds: Escape periods in oEmbed regex.
Props jrf. Fixes #38187. git-svn-id: https://develop.svn.wordpress.org/trunk@38684 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2a3ffbf498
commit
335cb0223f
@ -60,7 +60,7 @@ class WP_oEmbed {
|
||||
'#https?://youtu\.be/.*#i' => array( 'https://www.youtube.com/oembed', true ),
|
||||
'#https?://(.+\.)?vimeo\.com/.*#i' => array( 'https://vimeo.com/api/oembed.{format}', true ),
|
||||
'#https?://(www\.)?dailymotion\.com/.*#i' => array( 'https://www.dailymotion.com/services/oembed', true ),
|
||||
'#https?://dai.ly/.*#i' => array( 'https://www.dailymotion.com/services/oembed', true ),
|
||||
'#https?://dai\.ly/.*#i' => array( 'https://www.dailymotion.com/services/oembed', true ),
|
||||
'#https?://(www\.)?flickr\.com/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ),
|
||||
'#https?://flic\.kr/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ),
|
||||
'#https?://(.+\.)?smugmug\.com/.*#i' => array( 'https://api.smugmug.com/services/oembed/', true ),
|
||||
@ -68,14 +68,14 @@ class WP_oEmbed {
|
||||
'http://i*.photobucket.com/albums/*' => array( 'http://api.photobucket.com/oembed', false ),
|
||||
'http://gi*.photobucket.com/groups/*' => array( 'http://api.photobucket.com/oembed', false ),
|
||||
'#https?://(www\.)?scribd\.com/doc/.*#i' => array( 'https://www.scribd.com/services/oembed', true ),
|
||||
'#https?://wordpress.tv/.*#i' => array( 'https://wordpress.tv/oembed/', true ),
|
||||
'#https?://wordpress\.tv/.*#i' => array( 'https://wordpress.tv/oembed/', true ),
|
||||
'#https?://(.+\.)?polldaddy\.com/.*#i' => array( 'https://polldaddy.com/oembed/', true ),
|
||||
'#https?://poll\.fm/.*#i' => array( 'https://polldaddy.com/oembed/', true ),
|
||||
'#https?://(www\.)?funnyordie\.com/videos/.*#i' => array( 'http://www.funnyordie.com/oembed', true ),
|
||||
'#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i' => array( 'https://publish.twitter.com/oembed', true ),
|
||||
'#https?://(www\.)?twitter\.com/.+?/timelines/.*#i' => array( 'https://publish.twitter.com/oembed', true ),
|
||||
'#https?://(www\.)?twitter\.com/i/moments/.*#i' => array( 'https://publish.twitter.com/oembed', true ),
|
||||
'#https?://vine.co/v/.*#i' => array( 'https://vine.co/oembed.{format}', true ),
|
||||
'#https?://vine\.co/v/.*#i' => array( 'https://vine.co/oembed.{format}', true ),
|
||||
'#https?://(www\.)?soundcloud\.com/.*#i' => array( 'https://soundcloud.com/oembed', true ),
|
||||
'#https?://(.+?\.)?slideshare\.net/.*#i' => array( 'https://www.slideshare.net/api/oembed/2', true ),
|
||||
'#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' => array( 'https://api.instagram.com/oembed', true ),
|
||||
@ -92,7 +92,7 @@ class WP_oEmbed {
|
||||
'#https?://kck\.st/.*#i' => array( 'https://www.kickstarter.com/services/oembed', true ),
|
||||
'#https?://cloudup\.com/.*#i' => array( 'https://cloudup.com/oembed', true ),
|
||||
'#https?://(www\.)?reverbnation\.com/.*#i' => array( 'https://www.reverbnation.com/oembed', true ),
|
||||
'#https?://videopress.com/v/.*#' => array( 'https://public-api.wordpress.com/oembed/1.0/?for=' . $host, true ),
|
||||
'#https?://videopress\.com/v/.*#' => array( 'https://public-api.wordpress.com/oembed/1.0/?for=' . $host, true ),
|
||||
'#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => array( 'https://www.reddit.com/oembed', true ),
|
||||
'#https?://(www\.)?speakerdeck\.com/.*#i' => array( 'https://speakerdeck.com/oembed.{format}', true ),
|
||||
'#https?://www\.facebook\.com/.*/posts/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ),
|
||||
|
@ -8,7 +8,7 @@ class Tests_oEmbed extends WP_UnitTestCase {
|
||||
'youtube-shorturl' => '#https?://youtu\.be/.*#i',
|
||||
'vimeo' => '#https?://(.+\.)?vimeo\.com/.*#i',
|
||||
'dailymotion' => '#https?://(www\.)?dailymotion\.com/.*#i',
|
||||
'dailymotion-shorturl' => '#https?://dai.ly/.*#i',
|
||||
'dailymotion-shorturl' => '#https?://dai\.ly/.*#i',
|
||||
'flickr' => '#https?://(www\.)?flickr\.com/.*#i',
|
||||
'flickr-shorturl' => '#https?://flic\.kr/.*#i',
|
||||
'smugmug' => '#https?://(.+\.)?smugmug\.com/.*#i',
|
||||
@ -16,14 +16,14 @@ class Tests_oEmbed extends WP_UnitTestCase {
|
||||
'photobucket-album' => 'http://i*.photobucket.com/albums/*',
|
||||
'photobucket-group' => 'http://gi*.photobucket.com/groups/*',
|
||||
'scribd' => '#https?://(www\.)?scribd\.com/doc/.*#i',
|
||||
'wordpress-tv' => '#https?://wordpress.tv/.*#i',
|
||||
'wordpress-tv' => '#https?://wordpress\.tv/.*#i',
|
||||
'polldaddy' => '#https?://(.+\.)?polldaddy\.com/.*#i',
|
||||
'polldaddy-shorturl' => '#https?://poll\.fm/.*#i',
|
||||
'funnyordie' => '#https?://(www\.)?funnyordie\.com/videos/.*#i',
|
||||
'twitter' => '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i',
|
||||
'twitter-timeline' => '#https?://(www\.)?twitter\.com/.+?/timelines/.*#i',
|
||||
'twitter-moment' => '#https?://(www\.)?twitter\.com/i/moments/.*#i',
|
||||
'vine' => '#https?://vine.co/v/.*#i',
|
||||
'vine' => '#https?://vine\.co/v/.*#i',
|
||||
'soundcloud' => '#https?://(www\.)?soundcloud\.com/.*#i',
|
||||
'slideshare' => '#https?://(.+?\.)?slideshare\.net/.*#i',
|
||||
'instagram' => '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i',
|
||||
@ -40,7 +40,7 @@ class Tests_oEmbed extends WP_UnitTestCase {
|
||||
'kickstarter-shorturl' => '#https?://kck\.st/.*#i',
|
||||
'cloudup' => '#https?://cloudup\.com/.*#i',
|
||||
'reverbnation' => '#https?://(www\.)?reverbnation\.com/.*#i',
|
||||
'videopress' => '#https?://videopress.com/v/.*#',
|
||||
'videopress' => '#https?://videopress\.com/v/.*#',
|
||||
'reddit-comments' => '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i',
|
||||
'speakerdeck' => '#https?://(www\.)?speakerdeck\.com/.*#i',
|
||||
'facebook-post' => '#https?://www\.facebook\.com/.*/posts/.*#i',
|
||||
@ -812,4 +812,37 @@ class Tests_oEmbed extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test URLs that should not match any of the predefined providers.
|
||||
*
|
||||
* @group oembed
|
||||
* @ticket 38187
|
||||
*
|
||||
* @dataProvider dataShouldNotMatchOembedRegex
|
||||
*/
|
||||
public function testUrlShouldNotMatchOembedRegex( $url ) {
|
||||
|
||||
$this->assertSame( false, self::$oembed->get_provider( $url, array( 'discover' => false ) ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testUrlShouldNotMatchOembedRegex().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function dataShouldNotMatchOembedRegex() {
|
||||
$providers = self::$provider_map;
|
||||
|
||||
return array(
|
||||
array( 'http://dairly/something' ),
|
||||
array( 'https://daisly/' ),
|
||||
array( 'http://wordpressstv/' ),
|
||||
array( 'https://wordpressstv/somethingelse' ),
|
||||
array( 'http://vinerco/v/andanother' ),
|
||||
array( 'https://vineqco/v/' ),
|
||||
array( 'http://videopressscom/v/' ),
|
||||
array( 'https://videopresstcom/v/covered' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user