aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper')
-rw-r--r--src/Wallabag/CoreBundle/Helper/DownloadImages.php9
-rw-r--r--src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php5
2 files changed, 9 insertions, 5 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
index 0d330d2a..54e23a05 100644
--- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php
+++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
@@ -54,7 +54,7 @@ class DownloadImages
54 $crawler = new Crawler($html); 54 $crawler = new Crawler($html);
55 $result = $crawler 55 $result = $crawler
56 ->filterXpath('//img') 56 ->filterXpath('//img')
57 ->extract(array('src')); 57 ->extract(['src']);
58 58
59 $relativePath = $this->getRelativePath($entryId); 59 $relativePath = $this->getRelativePath($entryId);
60 60
@@ -66,6 +66,11 @@ class DownloadImages
66 continue; 66 continue;
67 } 67 }
68 68
69 // if image contains "&" and we can't find it in the html it might be because it's encoded as &
70 if (false !== stripos($image, '&') && false === stripos($html, $image)) {
71 $image = str_replace('&', '&', $image);
72 }
73
69 $html = str_replace($image, $imagePath, $html); 74 $html = str_replace($image, $imagePath, $html);
70 } 75 }
71 76
@@ -114,7 +119,7 @@ class DownloadImages
114 $ext = $this->mimeGuesser->guess($res->getHeader('content-type')); 119 $ext = $this->mimeGuesser->guess($res->getHeader('content-type'));
115 $this->logger->debug('DownloadImages: Checking extension', ['ext' => $ext, 'header' => $res->getHeader('content-type')]); 120 $this->logger->debug('DownloadImages: Checking extension', ['ext' => $ext, 'header' => $res->getHeader('content-type')]);
116 if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) { 121 if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) {
117 $this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping '.$imagePath); 122 $this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping: '.$imagePath);
118 123
119 return false; 124 return false;
120 } 125 }
diff --git a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
index 7d3798b9..df579ebd 100644
--- a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
+++ b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
@@ -20,16 +20,15 @@ class PreparePagerForEntries
20 20
21 /** 21 /**
22 * @param AdapterInterface $adapter 22 * @param AdapterInterface $adapter
23 * @param int $page
24 * 23 *
25 * @return null|Pagerfanta 24 * @return null|Pagerfanta
26 */ 25 */
27 public function prepare(AdapterInterface $adapter, $page = 1) 26 public function prepare(AdapterInterface $adapter)
28 { 27 {
29 $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; 28 $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
30 29
31 if (null === $user || !is_object($user)) { 30 if (null === $user || !is_object($user)) {
32 return null; 31 return;
33 } 32 }
34 33
35 $entries = new Pagerfanta($adapter); 34 $entries = new Pagerfanta($adapter);