git.cweiske.de
/
phorkie.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix DOMDocument usage on PHP 8.2
[phorkie.git]
/
src
/
phorkie
/
HtmlParser.php
diff --git
a/src/phorkie/HtmlParser.php
b/src/phorkie/HtmlParser.php
index b8cd1aff3dbece084445bde9617321aba0ae64bf..8102c69a42c6e45d4c79cefb4773dc7ff7926bb7 100644
(file)
--- a/
src/phorkie/HtmlParser.php
+++ b/
src/phorkie/HtmlParser.php
@@
-92,11
+92,14
@@
class HtmlParser
//$sx = simplexml_load_file($url);
libxml_use_internal_errors(true);
//$sx = simplexml_load_file($url);
libxml_use_internal_errors(true);
+ $domDoc = new \DOMDocument();
if ($html === null) {
if ($html === null) {
- $
sx = simplexml_import_dom(\DOMDocument::loadHTMLFile($url)
);
+ $
domDoc->loadHTMLFile($url
);
} else {
} else {
- $
sx = simplexml_import_dom(\DOMDocument::loadHTML($html)
);
+ $
domDoc->loadHTML($html
);
}
}
+ $sx = simplexml_import_dom($domDoc);
+ //FIXME: handle network error
$elems = $sx->xpath('//*[@rel="vcs-git"]');
$titles = $sx->xpath('/html/head/title');
$elems = $sx->xpath('//*[@rel="vcs-git"]');
$titles = $sx->xpath('/html/head/title');
@@
-173,6
+176,8
@@
class HtmlParser
public function getHtmlTitle($url)
{
libxml_use_internal_errors(true);
public function getHtmlTitle($url)
{
libxml_use_internal_errors(true);
+ //allow loading URLs in DOMDocument
+ libxml_disable_entity_loader(false);
$doc = \DOMDocument::loadHTMLFile($url);
if ($doc === false) {
return null;
$doc = \DOMDocument::loadHTMLFile($url);
if ($doc === false) {
return null;