mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-02-16 23:29:56 +03:00
[core] Fix XPathAbstract while working around Simple HTML DOM bug (#3408)
This commit is contained in:
parent
f803ffa79a
commit
87b9f2dd94
1 changed files with 17 additions and 6 deletions
23
lib/html.php
23
lib/html.php
|
@ -187,13 +187,24 @@ function defaultLinkTo($dom, $url)
|
|||
|
||||
// Use long method names for compatibility with simple_html_dom and DOMDocument
|
||||
|
||||
// foreach ($dom->getElementsByTagName('img', null) as $image) {
|
||||
// $image->setAttribute('src', urljoin($url, $image->getAttribute('src')));
|
||||
// }
|
||||
// Work around bug in simple_html_dom->getElementsByTagName
|
||||
if ($dom instanceof simple_html_dom) {
|
||||
$findByTag = function ($name) use ($dom) {
|
||||
return $dom->getElementsByTagName($name, null);
|
||||
};
|
||||
} else {
|
||||
$findByTag = function ($name) use ($dom) {
|
||||
return $dom->getElementsByTagName($name);
|
||||
};
|
||||
}
|
||||
|
||||
// foreach ($dom->getElementsByTagName('a', null) as $anchor) {
|
||||
// $anchor->setAttribute('href', urljoin($url, $anchor->getAttribute('href')));
|
||||
// }
|
||||
foreach ($findByTag('img') as $image) {
|
||||
$image->setAttribute('src', urljoin($url, $image->getAttribute('src')));
|
||||
}
|
||||
|
||||
foreach ($findByTag('a') as $anchor) {
|
||||
$anchor->setAttribute('href', urljoin($url, $anchor->getAttribute('href')));
|
||||
}
|
||||
|
||||
// Will never be true for DOMDocument
|
||||
if ($string_convert) {
|
||||
|
|
Loading…
Add table
Reference in a new issue