mirror of
https://github.com/friendica/friendica
synced 2025-04-25 03:50:12 +00:00
Avoid HTML parsing of an empty body
This commit is contained in:
parent
3e2fa7867c
commit
5a00902e11
7 changed files with 26 additions and 9 deletions
|
@ -1178,7 +1178,11 @@ class BBCode
|
|||
|
||||
// if its not a picture then look if its a page that contains a picture link
|
||||
$body = DI::httpRequest()->fetch($match[1]);
|
||||
|
||||
if (empty($body)) {
|
||||
DI::cache()->set($cache_key, $text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
$doc = new DOMDocument();
|
||||
@$doc->loadHTML($body);
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
@ -1214,8 +1218,6 @@ class BBCode
|
|||
|
||||
private static function cleanPictureLinksCallback($match)
|
||||
{
|
||||
$a = DI::app();
|
||||
|
||||
// When the picture link is the own photo path then we can avoid fetching the link
|
||||
$own_photo_url = preg_quote(Strings::normaliseLink(DI::baseUrl()->get()) . '/photos/');
|
||||
if (preg_match('|' . $own_photo_url . '.*?/image/|', Strings::normaliseLink($match[1]))) {
|
||||
|
@ -1257,6 +1259,10 @@ class BBCode
|
|||
|
||||
// if its not a picture then look if its a page that contains a picture link
|
||||
$body = DI::httpRequest()->fetch($match[1]);
|
||||
if (empty($body)) {
|
||||
DI::cache()->set($cache_key, $text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
$doc = new DOMDocument();
|
||||
@$doc->loadHTML($body);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue