use Friendica\Content\OEmbed;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
+use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
'oembed' => $do_oembed, 'content' => serialize($data),
'created' => DateTimeFormat::utcNow()
],
- true
+ Database::INSERT_UPDATE
);
return $data;
return $siteinfo;
}
- $curlResult = DI::httpRequest()->get($url, false, ['content_length' => 1000000]);
+ $curlResult = DI::httpRequest()->get($url);
if (!$curlResult->isSuccess()) {
return $siteinfo;
}
+ // If the file is too large then exit
+ if (($curlResult->getInfo()['download_content_length'] ?? 0) > 1000000) {
+ return $siteinfo;
+ }
+
// If it isn't a HTML file then exit
if (($curlResult->getContentType() != '') && !strstr(strtolower($curlResult->getContentType()), 'html')) {
return $siteinfo;
}
+ $header = $curlResult->getHeader();
$body = $curlResult->getBody();
if ($do_oembed) {
$charset = '';
// Look for a charset, first in headers
// Expected form: Content-Type: text/html; charset=ISO-8859-4
- if (preg_match('/charset=([a-z0-9-_.\/]+)/i', $curlResult->getContentType(), $matches)) {
+ if (preg_match('/charset=([a-z0-9-_.\/]+)/i', $header, $matches)) {
$charset = trim(trim(trim(array_pop($matches)), ';,'));
}