diff options
author | Mario <mario@mariovavti.com> | 2018-11-03 13:21:22 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2018-11-03 13:21:22 +0100 |
commit | 34e3f3907a6d8211c2b2486988f3d8e7c9eed085 (patch) | |
tree | 0ed028c6d31dfa02fc265e9c90d0a26d782147aa | |
parent | 24ae6c91ead39501c69838738db1b28eff222ea7 (diff) | |
parent | 46b0510b994fb885cd3c64b703ce73c2cee6d6c1 (diff) | |
download | volse-hubzilla-34e3f3907a6d8211c2b2486988f3d8e7c9eed085.tar.gz volse-hubzilla-34e3f3907a6d8211c2b2486988f3d8e7c9eed085.tar.bz2 volse-hubzilla-34e3f3907a6d8211c2b2486988f3d8e7c9eed085.zip |
Merge branch 'patch-22' into 'dev'
More precise content encoding detection on conversion
See merge request hubzilla/core!1363
-rw-r--r-- | Zotlabs/Module/Linkinfo.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php index a0ad17e68..670967370 100644 --- a/Zotlabs/Module/Linkinfo.php +++ b/Zotlabs/Module/Linkinfo.php @@ -228,8 +228,13 @@ class Linkinfo extends \Zotlabs\Web\Controller { $header = $result['header']; $body = $result['body']; + + // Check codepage in HTTP headers or HTML if not exist + $cp = (preg_match('/Content-Type: text\/html; charset=(.+)\r\n/i', $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', (preg_match('/meta.+content=["|\']text\/html;\s+charset=([^"|\']+)/i', $body, $o) ? $o[1] : 'UTF-8')); + $body = mb_convert_encoding($body, 'UTF-8', $cp); $body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8"); $doc = new \DOMDocument(); |