Make WordPress Core


Ignore:
Timestamp:
09/30/2016 11:24:08 AM (8 years ago)
Author:
SergeyBiryukov
Message:

Embeds: Escape periods in oEmbed regex.

Props jrf.
Fixes #38187.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/oembed.php

    r38514 r38684  
    99        'vimeo'                => '#https?://(.+\.)?vimeo\.com/.*#i',
    1010        'dailymotion'          => '#https?://(www\.)?dailymotion\.com/.*#i',
    11         'dailymotion-shorturl' => '#https?://dai.ly/.*#i',
     11        'dailymotion-shorturl' => '#https?://dai\.ly/.*#i',
    1212        'flickr'               => '#https?://(www\.)?flickr\.com/.*#i',
    1313        'flickr-shorturl'      => '#https?://flic\.kr/.*#i',
     
    1717        'photobucket-group'    => 'http://gi*.photobucket.com/groups/*',
    1818        'scribd'               => '#https?://(www\.)?scribd\.com/doc/.*#i',
    19         'wordpress-tv'         => '#https?://wordpress.tv/.*#i',
     19        'wordpress-tv'         => '#https?://wordpress\.tv/.*#i',
    2020        'polldaddy'            => '#https?://(.+\.)?polldaddy\.com/.*#i',
    2121        'polldaddy-shorturl'   => '#https?://poll\.fm/.*#i',
     
    2424        'twitter-timeline'     => '#https?://(www\.)?twitter\.com/.+?/timelines/.*#i',
    2525        'twitter-moment'       => '#https?://(www\.)?twitter\.com/i/moments/.*#i',
    26         'vine'                 => '#https?://vine.co/v/.*#i',
     26        'vine'                 => '#https?://vine\.co/v/.*#i',
    2727        'soundcloud'           => '#https?://(www\.)?soundcloud\.com/.*#i',
    2828        'slideshare'           => '#https?://(.+?\.)?slideshare\.net/.*#i',
     
    4141        'cloudup'              => '#https?://cloudup\.com/.*#i',
    4242        'reverbnation'         => '#https?://(www\.)?reverbnation\.com/.*#i',
    43         'videopress'           => '#https?://videopress.com/v/.*#',
     43        'videopress'           => '#https?://videopress\.com/v/.*#',
    4444        'reddit-comments'      => '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i',
    4545        'speakerdeck'          => '#https?://(www\.)?speakerdeck\.com/.*#i',
     
    813813    }
    814814
     815    /**
     816     * Test URLs that should not match any of the predefined providers.
     817     *
     818     * @group oembed
     819     * @ticket 38187
     820     *
     821     * @dataProvider dataShouldNotMatchOembedRegex
     822     */
     823    public function testUrlShouldNotMatchOembedRegex( $url ) {
     824
     825        $this->assertSame( false, self::$oembed->get_provider( $url, array( 'discover' => false ) ) );
     826
     827    }
     828
     829    /**
     830     * Data provider for testUrlShouldNotMatchOembedRegex().
     831     *
     832     * @return array
     833     */
     834    public function dataShouldNotMatchOembedRegex() {
     835        $providers = self::$provider_map;
     836
     837        return array(
     838            array( 'http://dairly/something' ),
     839            array( 'https://daisly/' ),
     840            array( 'http://wordpressstv/' ),
     841            array( 'https://wordpressstv/somethingelse' ),
     842            array( 'http://vinerco/v/andanother' ),
     843            array( 'https://vineqco/v/' ),
     844            array( 'http://videopressscom/v/' ),
     845            array( 'https://videopresstcom/v/covered' ),
     846        );
     847    }
    815848}
Note: See TracChangeset for help on using the changeset viewer.