Update Linkinfo.php

This commit is contained in:
Max Kostikov 2018-11-03 00:01:15 +01:00
parent a9bbe0b128
commit 2f3b4a7aaf

View File

@ -229,10 +229,10 @@ class Linkinfo extends \Zotlabs\Web\Controller {
$header = $result['header'];
$body = $result['body'];
// Check codepage in page or in HTTP headers if not exist
$cp = (preg_match('/meta.+content=["|\']text\/html; charset=([^"|\']+)/i', $body, $o) ? $o[1] : '');
if(empty($cp) || strtoupper($cp) == 'ISO-8859-5')
$cp = (preg_match('/Content-Type: text\/html; charset=(.+)/im', $header, $o) ? $o[1] : 'AUTO');
// Check codepage in HTTP headers or HTML if not exist
$cp = trim((preg_match('/Content-Type: text\/html; charset=(.+)/im', $header, $o) ? $o[1] : ''));
if(empty($cp))
$cp = (preg_match('/meta.+content=["|\']text\/html; charset=([^"|\']+)/i', $body, $o) ? $o[1] : 'AUTO');
$body = mb_convert_encoding($body, 'UTF-8', $cp);
$body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");