diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-22 14:21:14 +0400 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-22 14:21:14 +0400 |
commit | 785a085a5d7fbf502e9a2e9dce5c7bf899ca84fa (patch) | |
tree | ac1fb4352ad10c9d30a84166ab2cb664fdd97719 | |
parent | 19910df42e93ef370048e8d0d2609af71bf46676 (diff) |
better specify yt url
-rw-r--r-- | articleenhancer/globalarticleenhancer.php | 2 | ||||
-rw-r--r-- | tests/unit/articleenhancer/GlobalArticleEnhancerTest.php | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/articleenhancer/globalarticleenhancer.php b/articleenhancer/globalarticleenhancer.php index cfefb882b..512d51697 100644 --- a/articleenhancer/globalarticleenhancer.php +++ b/articleenhancer/globalarticleenhancer.php @@ -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); diff --git a/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php b/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php index 4b0db31a1..93f9273ed 100644 --- a/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php +++ b/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php @@ -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); |