summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ecd54aa)
It was only used to make an absolute url when downloading images.
The deps is still there (in the `composer.lock`) because Graby use it (not for absolute but for encoding).
"nelmio/api-doc-bundle": "^2.13.2",
"mgargano/simplehtmldom": "~1.5",
"wallabag/tcpdf": "^6.2.26",
"nelmio/api-doc-bundle": "^2.13.2",
"mgargano/simplehtmldom": "~1.5",
"wallabag/tcpdf": "^6.2.26",
- "simplepie/simplepie": "~1.5",
"willdurand/hateoas-bundle": "~1.3",
"liip/theme-bundle": "^1.4.6",
"lexik/form-filter-bundle": "^5.0.4",
"willdurand/hateoas-bundle": "~1.3",
"liip/theme-bundle": "^1.4.6",
"lexik/form-filter-bundle": "^5.0.4",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "883f44eda34a48c8ddabc3294498d996",
+ "content-hash": "c42e1b50f4a2b8a59ca06c5ccb24e6a3",
"packages": [
{
"name": "bdunogier/guzzle-site-authenticator",
"packages": [
{
"name": "bdunogier/guzzle-site-authenticator",
namespace Wallabag\CoreBundle\Helper;
namespace Wallabag\CoreBundle\Helper;
+use GuzzleHttp\Psr7\Uri;
+use GuzzleHttp\Psr7\UriResolver;
use Http\Client\Common\HttpMethodsClient;
use Http\Client\Common\Plugin\ErrorPlugin;
use Http\Client\Common\PluginClient;
use Http\Client\Common\HttpMethodsClient;
use Http\Client\Common\Plugin\ErrorPlugin;
use Http\Client\Common\PluginClient;
public static function extractImagesUrlsFromHtml($html)
{
$crawler = new Crawler($html);
public static function extractImagesUrlsFromHtml($html)
{
$crawler = new Crawler($html);
- $imagesCrawler = $crawler
- ->filterXpath('//img');
- $imagesUrls = $imagesCrawler
- ->extract(['src']);
+ $imagesCrawler = $crawler->filterXpath('//img');
+ $imagesUrls = $imagesCrawler->extract(['src']);
$imagesSrcsetUrls = self::getSrcsetUrls($imagesCrawler);
return array_unique(array_merge($imagesUrls, $imagesSrcsetUrls));
$imagesSrcsetUrls = self::getSrcsetUrls($imagesCrawler);
return array_unique(array_merge($imagesUrls, $imagesSrcsetUrls));
private static function getSrcsetUrls(Crawler $imagesCrawler)
{
$urls = [];
private static function getSrcsetUrls(Crawler $imagesCrawler)
{
$urls = [];
- $iterator = $imagesCrawler
- ->getIterator();
+ $iterator = $imagesCrawler->getIterator();
+
while ($iterator->valid()) {
$srcsetAttribute = $iterator->current()->getAttribute('srcset');
while ($iterator->valid()) {
$srcsetAttribute = $iterator->current()->getAttribute('srcset');
if ('' !== $srcsetAttribute) {
// Couldn't start with " OR ' OR a white space
// Could be one or more white space
// Must be one or more digits followed by w OR x
$pattern = "/(?:[^\"'\s]+\s*(?:\d+[wx])+)/";
preg_match_all($pattern, $srcsetAttribute, $matches);
if ('' !== $srcsetAttribute) {
// Couldn't start with " OR ' OR a white space
// Could be one or more white space
// Must be one or more digits followed by w OR x
$pattern = "/(?:[^\"'\s]+\s*(?:\d+[wx])+)/";
preg_match_all($pattern, $srcsetAttribute, $matches);
$srcset = \call_user_func_array('array_merge', $matches);
$srcsetUrls = array_map(function ($src) {
return trim(explode(' ', $src, 2)[0]);
}, $srcset);
$urls = array_merge($srcsetUrls, $urls);
}
$srcset = \call_user_func_array('array_merge', $matches);
$srcsetUrls = array_map(function ($src) {
return trim(explode(' ', $src, 2)[0]);
}, $srcset);
$urls = array_merge($srcsetUrls, $urls);
}
- $base = new \SimplePie_IRI($base);
+ $base = new Uri($base);
- // remove '//' in URL path (causes URLs not to resolve properly)
- if (isset($base->ipath)) {
- $base->ipath = preg_replace('!//+!', '/', $base->ipath);
- }
+ // in case the url has no scheme & host
+ if ('' === $base->getAuthority() || '' === $base->getScheme()) {
+ $this->logger->error('DownloadImages: Can not make an absolute link', ['base' => $base, 'url' => $url]);
- if ($absolute = \SimplePie_IRI::absolutize($base, $url)) {
- return $absolute->get_uri();
- $this->logger->error('DownloadImages: Can not make an absolute link', ['base' => $base, 'url' => $url]);
-
- return false;
+ return (string) UriResolver::resolve($base, new Uri($url));