use DOMDocument;
use DOMXPath;
use Friendica\Content\OEmbed;
-use Friendica\Core\Addon;
+use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\Object\Image;
-use Friendica\Util\Strings;
/**
* @brief Class with methods for extracting certain content from an url
*/
public static function getSiteinfo($url, $no_guessing = false, $do_oembed = true, $count = 1)
{
- $a = get_app();
+ $a = \get_app();
$siteinfo = [];
$charset = trim(trim(trim(array_pop($matches)), ';,'));
}
- if ($charset == '') {
- $charset = 'utf-8';
- }
+ if ($charset && strtoupper($charset) != 'UTF-8') {
+ // See https://github.com/friendica/friendica/issues/5470#issuecomment-418351211
+ $charset = str_ireplace('latin-1', 'latin1', $charset);
- if (($charset != '') && (strtoupper($charset) != 'UTF-8')) {
Logger::log('detected charset ' . $charset, Logger::DEBUG);
$body = iconv($charset, 'UTF-8//TRANSLIT', $body);
}
Logger::log('Siteinfo for ' . $url . ' ' . print_r($siteinfo, true), Logger::DEBUG);
- Addon::callHooks('getsiteinfo', $siteinfo);
+ Hook::callAll('getsiteinfo', $siteinfo);
return $siteinfo;
}