Fix parsing invalid href
See https://github.com/oscarotero/Embed/pull/502
This commit is contained in:
parent
f839fb1077
commit
d29a853be1
2 changed files with 25 additions and 1 deletions
|
@ -3,6 +3,8 @@ declare(strict_types = 1);
|
||||||
|
|
||||||
namespace Embed\Detectors;
|
namespace Embed\Detectors;
|
||||||
|
|
||||||
|
use function Embed\isEmpty;
|
||||||
|
|
||||||
class Languages extends Detector
|
class Languages extends Detector
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +19,7 @@ class Languages extends Detector
|
||||||
$language = $node->getAttribute('hreflang');
|
$language = $node->getAttribute('hreflang');
|
||||||
$href = $node->getAttribute('href');
|
$href = $node->getAttribute('href');
|
||||||
|
|
||||||
if (!$language || !$href) {
|
if (isEmpty($language, $href)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
vendor/embed/embed/src/functions.php
vendored
22
vendor/embed/embed/src/functions.php
vendored
|
@ -132,3 +132,25 @@ function getDirectory(string $path, int $position): ?string
|
||||||
$dirs = explode('/', $path);
|
$dirs = explode('/', $path);
|
||||||
return $dirs[$position + 1] ?? null;
|
return $dirs[$position + 1] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether at least one of the supplied variables is empty.
|
||||||
|
*
|
||||||
|
* @param mixed ...$values The values to check.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function isEmpty(mixed ...$values): bool
|
||||||
|
{
|
||||||
|
$skipValues = array(
|
||||||
|
'undefined',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($values as $value) {
|
||||||
|
if (empty($value) || in_array($value, $skipValues)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue