X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FHelper%2FContentProxy.php;h=ddecd6f4839de3c5e53c9f2638646f1269a0f5d8;hb=f808b01692a835673f328d7221ba8c212caa9b61;hp=e4e7fb3183c4bbbabc98918c6f8ba02e69990dee;hpb=42f3bb2c6346e04d2837f980bf685f7e32a61a21;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index e4e7fb31..ddecd6f4 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -4,12 +4,12 @@ namespace Wallabag\CoreBundle\Helper; use Graby\Graby; use Psr\Log\LoggerInterface; -use Wallabag\CoreBundle\Entity\Entry; -use Wallabag\CoreBundle\Tools\Utils; use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser; use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint; use Symfony\Component\Validator\Constraints\Url as UrlConstraint; use Symfony\Component\Validator\Validator\ValidatorInterface; +use Wallabag\CoreBundle\Entity\Entry; +use Wallabag\CoreBundle\Tools\Utils; /** * This kind of proxy class take care of getting the content from an url @@ -100,7 +100,7 @@ class ContentProxy // is it a timestamp? if (filter_var($date, FILTER_VALIDATE_INT) !== false) { - $date = '@'.$content['date']; + $date = '@' . $content['date']; } try { @@ -120,12 +120,12 @@ class ContentProxy $this->validateAndSetLanguage( $entry, - isset($content['language']) ? $content['language'] : '' + isset($content['language']) ? $content['language'] : null ); $this->validateAndSetPreviewPicture( $entry, - isset($content['open_graph']['og_image']) ? $content['open_graph']['og_image'] : '' + isset($content['open_graph']['og_image']) ? $content['open_graph']['og_image'] : null ); // if content is an image, define it as a preview too @@ -174,6 +174,10 @@ class ContentProxy */ private function validateAndSetLanguage($entry, $value) { + // some lang are defined as fr-FR, es-ES. + // replacing - by _ might increase language support + $value = str_replace('-', '_', $value); + $errors = $this->validator->validate( $value, (new LocaleConstraint()) @@ -185,7 +189,7 @@ class ContentProxy return; } - $this->logger->warning('Language validation failed. '.(string) $errors); + $this->logger->warning('Language validation failed. ' . (string) $errors); } /** @@ -207,6 +211,6 @@ class ContentProxy return; } - $this->logger->warning('PreviewPicture validation failed. '.(string) $errors); + $this->logger->warning('PreviewPicture validation failed. ' . (string) $errors); } }