summaryrefslogtreecommitdiffstats
path: root/vendor/fguillot/picofeed/tests/Filter
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/fguillot/picofeed/tests/Filter')
-rw-r--r--vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php6
-rw-r--r--vendor/fguillot/picofeed/tests/Filter/FilterTest.php96
-rw-r--r--vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php5
3 files changed, 95 insertions, 12 deletions
diff --git a/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php b/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php
index 907aaa2d5..bf7dd224e 100644
--- a/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php
+++ b/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php
@@ -39,8 +39,8 @@ class AttributeFilterTest extends PHPUnit_Framework_TestCase
$this->assertTrue($filter->filterIntegerAttribute('iframe', 'width', '450'));
$this->assertFalse($filter->filterIntegerAttribute('iframe', 'width', 'test'));
- $this->assertEquals(array('width' => '10', 'src' => 'http://www.youtube.com/test'), $filter->filter('iframe', array('width' => '10', 'src' => 'http://www.youtube.com/test')));
- $this->assertEquals(array('src' => 'http://www.youtube.com/test'), $filter->filter('iframe', array('width' => 'test', 'src' => 'http://www.youtube.com/test')));
+ $this->assertEquals(array('width' => '10', 'src' => 'https://www.youtube.com/test'), $filter->filter('iframe', array('width' => '10', 'src' => 'http://www.youtube.com/test')));
+ $this->assertEquals(array('src' => 'https://www.youtube.com/test'), $filter->filter('iframe', array('width' => 'test', 'src' => 'http://www.youtube.com/test')));
}
public function testRewriteProxyImageUrl()
@@ -125,7 +125,7 @@ class AttributeFilterTest extends PHPUnit_Framework_TestCase
$this->assertFalse($filter->filterIframeAttribute('iframe', 'src', '//www.youtube.com/test'));
$this->assertFalse($filter->filterIframeAttribute('iframe', 'src', '//www.bidule.com/test'));
- $this->assertEquals(array('src' => 'http://www.youtube.com/test'), $filter->filter('iframe', array('src' => '//www.youtube.com/test')));
+ $this->assertEquals(array('src' => 'https://www.youtube.com/test'), $filter->filter('iframe', array('src' => '//www.youtube.com/test')));
}
public function testFilterBlacklistAttribute()
diff --git a/vendor/fguillot/picofeed/tests/Filter/FilterTest.php b/vendor/fguillot/picofeed/tests/Filter/FilterTest.php
index bfcb8d970..f5f98a96b 100644
--- a/vendor/fguillot/picofeed/tests/Filter/FilterTest.php
+++ b/vendor/fguillot/picofeed/tests/Filter/FilterTest.php
@@ -71,10 +71,11 @@ class FilterTest extends PHPUnit_Framework_TestCase
public function testOverrideFilters()
{
$data = '<iframe src="http://www.kickstarter.com/projects/lefnire/habitrpg-mobile/widget/video.html" height="480" width="640" frameborder="0"></iframe>';
+ $expected = '<iframe src="https://www.kickstarter.com/projects/lefnire/habitrpg-mobile/widget/video.html" height="480" width="640" frameborder="0"></iframe>';
$f = Filter::html($data, 'http://blabla');
$f->attribute->setIframeWhitelist(array('http://www.kickstarter.com'));
- $this->assertEquals($data, $f->execute());
+ $this->assertEquals($expected, $f->execute());
$data = '<iframe src="http://www.youtube.com/bla" height="480" width="640" frameborder="0"></iframe>';
@@ -90,7 +91,7 @@ class FilterTest extends PHPUnit_Framework_TestCase
$this->assertEquals('<p>Testboo</p>', $f->execute());
}
- public function testImageProxy()
+ public function testNoImageProxySet()
{
$f = Filter::html('<p>Image <img src="/image.png" alt="My Image"/></p>', 'http://foo');
@@ -98,10 +99,71 @@ class FilterTest extends PHPUnit_Framework_TestCase
'<p>Image <img src="http://foo/image.png" alt="My Image"/></p>',
$f->execute()
);
+ }
+
+ public function testImageProxyWithHTTPLink()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+
+ $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://myproxy/?url='.rawurlencode('http://localhost/image.png').'" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testImageProxyWithHTTPSLink()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+
+ $f = Filter::html('<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://myproxy/?url='.rawurlencode('https://localhost/image.png').'" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testImageProxyLimitedToUnknownProtocol()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+ $config->setFilterImageProxyProtocol('tripleX');
+
+ $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
+
+ public function testImageProxyLimitedToHTTPwithHTTPLink()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+ $config->setFilterImageProxyProtocol('http');
+
+ $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://myproxy/?url='.rawurlencode('http://localhost/image.png').'" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
- // Test setFilterImageProxyUrl and HTTPS
+ public function testImageProxyLimitedToHTTPwithHTTPSLink()
+ {
$config = new Config;
$config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+ $config->setFilterImageProxyProtocol('http');
$f = Filter::html('<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>', 'http://foo');
$f->setConfig($config);
@@ -110,20 +172,40 @@ class FilterTest extends PHPUnit_Framework_TestCase
'<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>',
$f->execute()
);
+ }
+
+ public function testImageProxyLimitedToHTTPSwithHTTPLink()
+ {
+ $config = new Config;
+ $config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+ $config->setFilterImageProxyProtocol('https');
+
+ $f = Filter::html('<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>', 'http://foo');
+ $f->setConfig($config);
+
+ $this->assertEquals(
+ '<p>Image <img src="http://localhost/image.png" alt="My Image"/></p>',
+ $f->execute()
+ );
+ }
- // Test setFilterImageProxyUrl
+ public function testImageProxyLimitedToHTTPSwithHTTPSLink()
+ {
$config = new Config;
$config->setFilterImageProxyUrl('http://myproxy/?url=%s');
+ $config->setFilterImageProxyProtocol('https');
- $f = Filter::html('<p>Image <img src="/image.png" alt="My Image"/></p>', 'http://foo');
+ $f = Filter::html('<p>Image <img src="https://localhost/image.png" alt="My Image"/></p>', 'http://foo');
$f->setConfig($config);
$this->assertEquals(
- '<p>Image <img src="http://myproxy/?url='.rawurlencode('http://foo/image.png').'" alt="My Image"/></p>',
+ '<p>Image <img src="http://myproxy/?url='.rawurlencode('https://localhost/image.png').'" alt="My Image"/></p>',
$f->execute()
);
+ }
- // Test setFilterImageProxyCallback
+ public function testsetFilterImageProxyCallback()
+ {
$config = new Config;
$config->setFilterImageProxyCallback(function ($image_url) {
$key = hash_hmac('sha1', $image_url, 'secret');
diff --git a/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php b/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php
index 271167481..5093855d1 100644
--- a/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php
+++ b/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php
@@ -25,9 +25,10 @@ class HtmlFilterTest extends PHPUnit_Framework_TestCase
$this->assertEmpty($f->execute());
$data = '<iframe src="http://www.youtube.com/bla" height="480" width="640" frameborder="0"></iframe>';
+ $expected = '<iframe src="https://www.youtube.com/bla" height="480" width="640" frameborder="0"></iframe>';
$f = new Html($data, 'http://blabla');
- $this->assertEquals($data, $f->execute());
+ $this->assertEquals($expected, $f->execute());
}
public function testEmptyTags()
@@ -50,7 +51,7 @@ EOD;
$data = '<iframe src="http://www.youtube.com/bla" height="480px" width="100%" frameborder="0"></iframe>';
$f = new Html($data, 'http://blabla');
- $this->assertEquals('<iframe src="http://www.youtube.com/bla" frameborder="0"></iframe>', $f->execute());
+ $this->assertEquals('<iframe src="https://www.youtube.com/bla" frameborder="0"></iframe>', $f->execute());
}
public function testRelativeScheme()