1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2025-04-09 10:15:44 +02:00

better specify yt url

This commit is contained in:
Bernhard Posselt 2014-09-22 12:21:14 +02:00
parent 19910df42e
commit 785a085a5d
2 changed files with 3 additions and 3 deletions
articleenhancer
tests/unit/articleenhancer

View File

@ -38,7 +38,7 @@ class GlobalArticleEnhancer implements ArticleEnhancer {
// src needs to be matched against regex to prevent false positives
// and because theres no XPath matches function available
$src = $element->getAttribute('src');
$regex = '%^(http://|https://|//)(www\.)?youtube.com/.*autoplay=1.*%i';
$regex = '%^(http://|https://|//)(www\.)?youtube.com/.*\?.*autoplay=1.*%i';
if (preg_match($regex, $src)) {
$replaced = str_replace('autoplay=1', 'autoplay=0', $src);

View File

@ -26,8 +26,8 @@ class GlobalArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
public function testNoReplaceYoutubeAutoplay() {
$body = '<iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?autoplay=0" frameborder="0" allowfullscreen=""></iframe>';
$expected = '<iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?autoplay=0" frameborder="0" allowfullscreen=""></iframe>';
$body = '<iframe width="728" height="410" src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" frameborder="0" allowfullscreen=""></iframe>';
$expected = '<iframe width="728" height="410" src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" frameborder="0" allowfullscreen=""></iframe>';
$item = new Item();
$item->setBody($body);