forked from wallabag/wallabag
Remove htmlawed and use graby instead
Instead of using htmlawed (which is already used in graby) use graby directly (which require some refacto on graby side). Still needs some tests.
This commit is contained in:
@ -61,7 +61,6 @@
|
|||||||
"wallabag/tcpdf": "^6.2",
|
"wallabag/tcpdf": "^6.2",
|
||||||
"simplepie/simplepie": "~1.3.1",
|
"simplepie/simplepie": "~1.3.1",
|
||||||
"willdurand/hateoas-bundle": "~1.0",
|
"willdurand/hateoas-bundle": "~1.0",
|
||||||
"htmlawed/htmlawed": "~1.1.19",
|
|
||||||
"liip/theme-bundle": "~1.1",
|
"liip/theme-bundle": "~1.1",
|
||||||
"lexik/form-filter-bundle": "~5.0",
|
"lexik/form-filter-bundle": "~5.0",
|
||||||
"j0k3r/graby": "dev-extractor",
|
"j0k3r/graby": "dev-extractor",
|
||||||
|
|||||||
@ -47,24 +47,7 @@ class ContentProxy
|
|||||||
{
|
{
|
||||||
// ensure content is a bit cleaned up
|
// ensure content is a bit cleaned up
|
||||||
if (!empty($content['html'])) {
|
if (!empty($content['html'])) {
|
||||||
$extractor = $this->graby->getExtractor();
|
$content['html'] = $this->graby->cleanupHtml($content['html'], $url);
|
||||||
$contentExtracted = $extractor->process($content['html'], $url);
|
|
||||||
|
|
||||||
if ($contentExtracted) {
|
|
||||||
$contentBlock = $extractor->getContent();
|
|
||||||
$contentBlock->normalize();
|
|
||||||
|
|
||||||
$content['html'] = trim($contentBlock->innerHTML);
|
|
||||||
}
|
|
||||||
|
|
||||||
$content['html'] = htmLawed($content['html'], [
|
|
||||||
'safe' => 1,
|
|
||||||
// which means: do not remove iframe elements
|
|
||||||
'elements' => '*+iframe',
|
|
||||||
'deny_attribute' => 'style',
|
|
||||||
'comment' => 1,
|
|
||||||
'cdata' => 1,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// do we have to fetch the content or the provided one is ok?
|
// do we have to fetch the content or the provided one is ok?
|
||||||
|
|||||||
@ -210,16 +210,18 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
|
|||||||
$tagger->expects($this->once())
|
$tagger->expects($this->once())
|
||||||
->method('tag');
|
->method('tag');
|
||||||
|
|
||||||
$graby = $this->getMockBuilder('Graby\Graby')->getMock();
|
$proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage);
|
||||||
|
$entry = $proxy->updateEntry(
|
||||||
$proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
|
new Entry(new User()),
|
||||||
$entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [
|
'http://0.0.0.0',
|
||||||
'html' => str_repeat('this is my content', 325),
|
[
|
||||||
'title' => 'this is my title',
|
'html' => str_repeat('this is my content', 325),
|
||||||
'url' => 'http://1.1.1.1',
|
'title' => 'this is my title',
|
||||||
'content_type' => 'text/html',
|
'url' => 'http://1.1.1.1',
|
||||||
'language' => 'fr',
|
'content_type' => 'text/html',
|
||||||
]);
|
'language' => 'fr',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
|
$this->assertEquals('http://1.1.1.1', $entry->getUrl());
|
||||||
$this->assertEquals('this is my title', $entry->getTitle());
|
$this->assertEquals('this is my title', $entry->getTitle());
|
||||||
@ -277,9 +279,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
|
|||||||
$tagger->expects($this->once())
|
$tagger->expects($this->once())
|
||||||
->method('tag');
|
->method('tag');
|
||||||
|
|
||||||
$graby = new Graby();
|
$proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage);
|
||||||
|
|
||||||
$proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
|
|
||||||
$entry = $proxy->updateEntry(
|
$entry = $proxy->updateEntry(
|
||||||
new Entry(new User()),
|
new Entry(new User()),
|
||||||
'http://1.1.1.1',
|
'http://1.1.1.1',
|
||||||
|
|||||||
Reference in New Issue
Block a user