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