aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Linkinfo.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Linkinfo.php')
-rw-r--r--Zotlabs/Module/Linkinfo.php44
1 files changed, 36 insertions, 8 deletions
diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php
index a0ad17e68..7c7dc0e88 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();
@@ -265,20 +270,43 @@ class Linkinfo extends \Zotlabs\Web\Controller {
$attr["content"] = html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8");
switch (strtolower($attr["name"])) {
- case 'generator':
- $siteinfo['generator'] = $attr['content'];
- break;
case "fulltitle":
- $siteinfo["title"] = $attr["content"];
+ $siteinfo["title"] = trim($attr["content"]);
break;
case "description":
- $siteinfo["text"] = $attr["content"];
+ $siteinfo["text"] = trim($attr["content"]);
+ break;
+ case "thumbnail":
+ $siteinfo["image"] = $attr["content"];
+ break;
+ case "twitter:image":
+ $siteinfo["image"] = $attr["content"];
+ break;
+ case "twitter:image:src":
+ $siteinfo["image"] = $attr["content"];
+ break;
+ case "twitter:card":
+ if (($siteinfo["type"] == "") || ($attr["content"] == "photo")) {
+ $siteinfo["type"] = $attr["content"];
+ }
+ break;
+ case "twitter:description":
+ $siteinfo["text"] = trim($attr["content"]);
+ break;
+ case "twitter:title":
+ $siteinfo["title"] = trim($attr["content"]);
break;
case "dc.title":
- $siteinfo["title"] = $attr["content"];
+ $siteinfo["title"] = trim($attr["content"]);
break;
case "dc.description":
- $siteinfo["text"] = $attr["content"];
+ $siteinfo["text"] = trim($attr["content"]);
+ break;
+ case "keywords":
+ $keywords = explode(",", $attr["content"]);
+ break;
+ case "news_keywords":
+ $keywords = explode(",", $attr["content"]);
break;
}
}