[core] Fix defaultLinkTo for simple_html_dom objects (#3404)

This commit is contained in:
mrnoname1000 2023-05-19 17:02:17 -05:00 committed by GitHub
parent cfe81ab2ac
commit 3e0d024888
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 10 deletions

View File

@ -187,18 +187,12 @@ function defaultLinkTo($dom, $url)
// Use long method names for compatibility with simple_html_dom and DOMDocument // Use long method names for compatibility with simple_html_dom and DOMDocument
$images = $dom->getElementsByTagName('img'); foreach ($dom->getElementsByTagName('img', null) as $image) {
if (is_array($images)) { $image->setAttribute('src', urljoin($url, $image->getAttribute('src')));
foreach ($images as $image) {
$image->setAttribute('src', urljoin($url, $image->getAttribute('src')));
}
} }
$anchors = $dom->getElementsByTagName('a'); foreach ($dom->getElementsByTagName('a', null) as $anchor) {
if (is_array($anchors)) { $anchor->setAttribute('href', urljoin($url, $anchor->getAttribute('href')));
foreach ($anchors as $anchor) {
$anchor->setAttribute('href', urljoin($url, $anchor->getAttribute('href')));
}
} }
// Will never be true for DOMDocument // Will never be true for DOMDocument