boo
boo
';
$this->assertEquals($expected, Filter::stripHeadTags($input));
$input = file_get_contents('tests/fixtures/html4_page.html');
$expected = file_get_contents('tests/fixtures/html4_head_stripped_page.html');
$this->assertEquals($expected, Filter::stripHeadTags($input));
$input = file_get_contents('tests/fixtures/html_page.html');
$expected = file_get_contents('tests/fixtures/html_head_stripped_page.html');
$this->assertEquals($expected, Filter::stripHeadTags($input));
}
public function testStripXmlTag()
{
$data = file_get_contents('tests/fixtures/jeux-linux.fr.xml');
$this->assertEquals('assertEquals('assertEquals('assertEquals('assertEquals('assertEquals('assertEquals('assertEquals('assertEquals('assertEquals('assertEquals('assertEquals('assertEquals('assertEquals('';
$f = Filter::html($data, 'http://blabla');
$f->attribute->setIframeWhitelist(array('http://www.kickstarter.com'));
$this->assertEquals($data, $f->execute());
$data = '';
$f = Filter::html($data, 'http://blabla');
$f->attribute->setIframeWhitelist(array('http://www.kickstarter.com'));
$this->assertEmpty($f->execute());
$config = new Config;
$config->setFilterWhitelistedTags(array('p' => array('title')));
$f = Filter::html('Testboo
', 'http://blabla');
$f->setConfig($config);
$this->assertEquals('Testboo
', $f->execute());
}
public function testImageProxy()
{
$f = Filter::html('Image ![My Image](/image.png)
', 'http://foo');
$this->assertEquals(
'Image ![My Image](http://foo/image.png)
',
$f->execute()
);
// Test setFilterImageProxyUrl and HTTPS
$config = new Config;
$config->setFilterImageProxyUrl('http://myproxy/?url=%s');
$f = Filter::html('Image ![My Image](https://localhost/image.png)
', 'http://foo');
$f->setConfig($config);
$this->assertEquals(
'Image ![My Image](https://localhost/image.png)
',
$f->execute()
);
// Test setFilterImageProxyUrl
$config = new Config;
$config->setFilterImageProxyUrl('http://myproxy/?url=%s');
$f = Filter::html('Image ![My Image](/image.png)
', 'http://foo');
$f->setConfig($config);
$this->assertEquals(
'Image ![My Image](http://myproxy/?url='.rawurlencode('http://foo/image.png').')
',
$f->execute()
);
// Test setFilterImageProxyCallback
$config = new Config;
$config->setFilterImageProxyCallback(function ($image_url) {
$key = hash_hmac('sha1', $image_url, 'secret');
return 'https://mypublicproxy/'.$key.'/'.rawurlencode($image_url);
});
$f = Filter::html('Image ![My Image](/image.png)
', 'http://foo');
$f->setConfig($config);
$this->assertEquals(
'Image ![My Image](https://mypublicproxy/4924964043f3119b3cf2b07b1922d491bcc20092/'.rawurlencode('http://foo/image.png').')
',
$f->execute()
);
}
}