diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-02-07 17:56:05 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-05-28 11:44:20 +0200 |
commit | b6c1e1bacc59ba761d1b47ac6611d1db800f7252 (patch) | |
tree | d6724737f4ed6bcaebc73b572495b440a5c19553 /src/Wallabag/CoreBundle | |
parent | a91a3150fbc4446e379cc23618db8f74e4044515 (diff) | |
download | wallabag-b6c1e1bacc59ba761d1b47ac6611d1db800f7252.tar.gz wallabag-b6c1e1bacc59ba761d1b47ac6611d1db800f7252.tar.zst wallabag-b6c1e1bacc59ba761d1b47ac6611d1db800f7252.zip |
Fix some tests
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/ContentProxy.php | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index ac27e50a..59465ad1 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php | |||
@@ -54,7 +54,11 @@ class ContentProxy | |||
54 | 54 | ||
55 | if ((empty($content) || false === $this->validateContent($content)) && false === $disableContentUpdate) { | 55 | if ((empty($content) || false === $this->validateContent($content)) && false === $disableContentUpdate) { |
56 | $fetchedContent = $this->graby->fetchContent($url); | 56 | $fetchedContent = $this->graby->fetchContent($url); |
57 | $fetchedContent['title'] = $this->sanitizeContentTitle($fetchedContent['title'], $fetchedContent['content_type']); | 57 | |
58 | $fetchedContent['title'] = $this->sanitizeContentTitle( | ||
59 | $fetchedContent['title'], | ||
60 | isset($fetchedContent['headers']['content-type']) ? $fetchedContent['headers']['content-type'] : '' | ||
61 | ); | ||
58 | 62 | ||
59 | // when content is imported, we have information in $content | 63 | // when content is imported, we have information in $content |
60 | // in case fetching content goes bad, we'll keep the imported information instead of overriding them | 64 | // in case fetching content goes bad, we'll keep the imported information instead of overriding them |
@@ -188,8 +192,8 @@ class ContentProxy | |||
188 | /** | 192 | /** |
189 | * Try to sanitize the title of the fetched content from wrong character encodings and invalid UTF-8 character. | 193 | * Try to sanitize the title of the fetched content from wrong character encodings and invalid UTF-8 character. |
190 | * | 194 | * |
191 | * @param $title | 195 | * @param string $title |
192 | * @param $contentType | 196 | * @param string $contentType |
193 | * | 197 | * |
194 | * @return string | 198 | * @return string |
195 | */ | 199 | */ |
@@ -293,12 +297,15 @@ class ContentProxy | |||
293 | } | 297 | } |
294 | 298 | ||
295 | // if content is an image, define it as a preview too | 299 | // if content is an image, define it as a preview too |
296 | if (!empty($content['headers']['content_type']) && \in_array($this->mimeGuesser->guess($content['headers']['content_type']), ['jpeg', 'jpg', 'gif', 'png'], true)) { | 300 | if (!empty($content['headers']['content-type']) && \in_array($this->mimeGuesser->guess($content['headers']['content-type']), ['jpeg', 'jpg', 'gif', 'png'], true)) { |
297 | $previewPictureUrl = $content['url']; | 301 | $previewPictureUrl = $content['url']; |
302 | |||
303 | $entry->setMimetype($content['headers']['content-type']); | ||
298 | } elseif (empty($previewPictureUrl)) { | 304 | } elseif (empty($previewPictureUrl)) { |
299 | $this->logger->debug('Extracting images from content to provide a default preview picture'); | 305 | $this->logger->debug('Extracting images from content to provide a default preview picture'); |
300 | $imagesUrls = DownloadImages::extractImagesUrlsFromHtml($content['html']); | 306 | $imagesUrls = DownloadImages::extractImagesUrlsFromHtml($content['html']); |
301 | $this->logger->debug(\count($imagesUrls) . ' pictures found'); | 307 | $this->logger->debug(\count($imagesUrls) . ' pictures found'); |
308 | |||
302 | if (!empty($imagesUrls)) { | 309 | if (!empty($imagesUrls)) { |
303 | $previewPictureUrl = $imagesUrls[0]; | 310 | $previewPictureUrl = $imagesUrls[0]; |
304 | } | 311 | } |
@@ -308,10 +315,6 @@ class ContentProxy | |||
308 | $this->updatePreviewPicture($entry, $previewPictureUrl); | 315 | $this->updatePreviewPicture($entry, $previewPictureUrl); |
309 | } | 316 | } |
310 | 317 | ||
311 | if (!empty($content['headers']['content-type'])) { | ||
312 | $entry->setMimetype($content['headers']['content-type']); | ||
313 | } | ||
314 | |||
315 | try { | 318 | try { |
316 | $this->tagger->tag($entry); | 319 | $this->tagger->tag($entry); |
317 | } catch (\Exception $e) { | 320 | } catch (\Exception $e) { |