Merge pull request #10066 from annando/decode

ParseUrl: Perform entity decode afterwards
This commit is contained in:
Hypolite Petovan 2021-03-22 09:43:59 -04:00 committed by GitHub
commit aaf94531a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -466,8 +466,7 @@ class ParseUrl
$list = $xpath->query("//script[@type='application/ld+json']"); $list = $xpath->query("//script[@type='application/ld+json']");
foreach ($list as $node) { foreach ($list as $node) {
if (!empty($node->nodeValue)) { if (!empty($node->nodeValue)) {
$nodevalue = html_entity_decode($node->nodeValue, ENT_COMPAT, 'UTF-8'); if ($jsonld = json_decode($node->nodeValue, true)) {
if ($jsonld = json_decode($nodevalue, true)) {
$siteinfo = self::parseParts($siteinfo, $jsonld); $siteinfo = self::parseParts($siteinfo, $jsonld);
} }
} }
@ -701,10 +700,16 @@ class ParseUrl
if ($numeric_keys) { if ($numeric_keys) {
foreach ($jsonld as $part) { foreach ($jsonld as $part) {
$siteinfo = self::parseParts($siteinfo, $part); $siteinfo = self::parseParts($siteinfo, $part);
} }
} }
} }
array_walk_recursive($siteinfo, function (&$element) {
if (is_string($element)) {
$element = html_entity_decode($element, ENT_COMPAT, 'UTF-8');
}
});
return $siteinfo; return $siteinfo;
} }