From 99f1aedd70a37b8763f0d72e0db223ede62190f3 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 15 Apr 2015 11:23:49 +0200 Subject: remove youtube autoplay in picofeed --- vendor/fguillot/picofeed/LICENSE | 21 +++++++++++++++++++ vendor/fguillot/picofeed/README.markdown | 2 +- vendor/fguillot/picofeed/UNLICENSE | 24 ---------------------- vendor/fguillot/picofeed/composer.json | 2 +- .../picofeed/lib/PicoFeed/Filter/Attribute.php | 20 ++++++++++++++++++ .../picofeed/lib/PicoFeed/Rules/vuxml.org.php | 13 ++++++++++++ .../picofeed/tests/Filter/AttributeFilterTest.php | 18 ++++++++++++++++ 7 files changed, 74 insertions(+), 26 deletions(-) create mode 100644 vendor/fguillot/picofeed/LICENSE delete mode 100644 vendor/fguillot/picofeed/UNLICENSE create mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Rules/vuxml.org.php (limited to 'vendor/fguillot/picofeed') diff --git a/vendor/fguillot/picofeed/LICENSE b/vendor/fguillot/picofeed/LICENSE new file mode 100644 index 000000000..6a362bc16 --- /dev/null +++ b/vendor/fguillot/picofeed/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Frederic Guillot + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/fguillot/picofeed/README.markdown b/vendor/fguillot/picofeed/README.markdown index 4a958c24c..957dc3a1b 100644 --- a/vendor/fguillot/picofeed/README.markdown +++ b/vendor/fguillot/picofeed/README.markdown @@ -24,7 +24,7 @@ Features - Content grabber: download from the original website the full content - Enclosure detection - RTL languages support -- License: Unlicense +- License: MIT Requirements ------------ diff --git a/vendor/fguillot/picofeed/UNLICENSE b/vendor/fguillot/picofeed/UNLICENSE deleted file mode 100644 index 68a49daad..000000000 --- a/vendor/fguillot/picofeed/UNLICENSE +++ /dev/null @@ -1,24 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to diff --git a/vendor/fguillot/picofeed/composer.json b/vendor/fguillot/picofeed/composer.json index 4c13bd6ab..56a5ee27e 100644 --- a/vendor/fguillot/picofeed/composer.json +++ b/vendor/fguillot/picofeed/composer.json @@ -3,7 +3,7 @@ "description": "Modern library to write or read feeds (RSS/Atom)", "homepage": "http://fguillot.github.io/picoFeed", "type": "library", - "license": "Unlicense", + "license": "MIT", "authors": [ { "name": "Frédéric Guillot", diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php index ae77ff714..ec1dac417 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php @@ -235,6 +235,7 @@ class Attribute 'filterProtocolUrlAttribute', 'rewriteImageProxyUrl', 'secureIframeSrc', + 'removeYouTubeAutoplay' ); /** @@ -404,6 +405,25 @@ class Attribute return true; } + /** + * Removes YouTube autoplay from iframes + * + * @access public + * @param string $tag Tag name + * @param array $attribute Atttributes name + * @param string $value Attribute value + * @return boolean + */ + public function removeYouTubeAutoplay($tag, $attribute, &$value) + { + $regex = '%^(https://(?:www\.)?youtube.com/.*\?.*autoplay=)(1)(.*)%i'; + if ($tag === 'iframe' && $attribute === 'src' && preg_match($regex, $value)) { + $value = preg_replace($regex, '${1}0$3', $value); + } + + return true; + } + /** * Rewrite image url to use with a proxy * diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/vuxml.org.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/vuxml.org.php new file mode 100644 index 000000000..dd433828b --- /dev/null +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/vuxml.org.php @@ -0,0 +1,13 @@ + 'http://www.vuxml.org/freebsd/a5f160fa-deee-11e4-99f8-080027ef73ec.html', + 'body' => array( + '//body' + ), + 'strip' => array( + '//h1', + '//div[@class="blurb"]', + '//hr', + '//p[@class="copyright"]' + ) +); \ No newline at end of file diff --git a/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php b/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php index bf7dd224e..5dcfda141 100644 --- a/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php +++ b/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php @@ -128,6 +128,24 @@ class AttributeFilterTest extends PHPUnit_Framework_TestCase $this->assertEquals(array('src' => 'https://www.youtube.com/test'), $filter->filter('iframe', array('src' => '//www.youtube.com/test'))); } + public function testRemoveYouTubeAutoplay() + { + $filter = new Attribute(new Url('http://google.com')); + $urls = array( + 'https://www.youtube.com/something/?autoplay=1' => 'https://www.youtube.com/something/?autoplay=0', + 'https://www.youtube.com/something/?test=s&autoplay=1&a=2' => 'https://www.youtube.com/something/?test=s&autoplay=0&a=2', + 'https://www.youtube.com/something/?test=s' => 'https://www.youtube.com/something/?test=s', + 'https://youtube.com/something/?autoplay=1' => 'https://youtube.com/something/?autoplay=0', + 'https://youtube.com/something/?test=s&autoplay=1&a=2' => 'https://youtube.com/something/?test=s&autoplay=0&a=2', + 'https://youtube.com/something/?test=s' => 'https://youtube.com/something/?test=s', + ); + + foreach ($urls as $before => $after) { + $filter->removeYouTubeAutoplay('iframe', 'src', $before); + $this->assertEquals($after, $before); + } + } + public function testFilterBlacklistAttribute() { $filter = new Attribute(new Url('http://google.com')); -- cgit v1.2.3