From efb32a74f9bd1c8e16223ac33b98018390ba9d98 Mon Sep 17 00:00:00 2001 From: Jay MOULIN Date: Sun, 24 Nov 2019 20:51:58 +0100 Subject: [PATCH] fixes #18 - encode special quotes for myhentaigallery.com --- src/Driver/MyHentaiGallery.php | 5 ++++- tests/Driver/MyHentaiGallery.php | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Driver/MyHentaiGallery.php b/src/Driver/MyHentaiGallery.php index 451cc0e7..8ab6f7e7 100644 --- a/src/Driver/MyHentaiGallery.php +++ b/src/Driver/MyHentaiGallery.php @@ -35,7 +35,10 @@ public function getDownloadables(): array /** * @var \PHPHtmlParser\Dom\AbstractNode $oImg */ - $sFilename = str_replace('/thumbnail/', '/original/', $oImg->getAttribute('src')); + $sFilename = html_entity_decode( + str_replace('/thumbnail/', '/original/', $oImg->getAttribute('src')), + ENT_QUOTES + ); $iPos = strpos($sFilename, '?'); if ($iPos) { $sFilename = substr($sFilename, 0, $iPos); diff --git a/tests/Driver/MyHentaiGallery.php b/tests/Driver/MyHentaiGallery.php index 84c0c471..0157ea93 100644 --- a/tests/Driver/MyHentaiGallery.php +++ b/tests/Driver/MyHentaiGallery.php @@ -16,4 +16,16 @@ public function testDownload() $this->assertTrue($driver->canHandle()); $this->assertEquals(53, count($driver->getDownloadables())); } + + /** + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function testDownloadSpecial() + { + $url = 'https://myhentaigallery.com/gallery/thumbnails/14053'; + $driver = new \Yamete\Driver\MyHentaiGallery(); + $driver->setUrl($url); + $this->assertTrue($driver->canHandle()); + $this->assertEquals(21, count($driver->getDownloadables())); + } }