]> git.mxchange.org Git - friendica.git/blobdiff - mod/parse_url.php
Moved "privacy_image_cache" into the core. Enabled by default, can be disabled in...
[friendica.git] / mod / parse_url.php
index 7ab71a2fc520d7f7ae68a07711a7cc35fe947633..5048f4fa53903ac6ea90d74eb7d827ff6928cf54 100644 (file)
@@ -71,8 +71,7 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
        curl_setopt($ch, CURLOPT_TIMEOUT, 3);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
-       //curl_setopt($ch,CURLOPT_USERAGENT,' Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0');
-       curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)");
+       curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION.")");
 
        $header = curl_exec($ch);
        $curl_info = @curl_getinfo($ch);
@@ -100,7 +99,7 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
        // Fetch the first mentioned charset. Can be in body or header
        $charset = "";
        if (preg_match('/charset=(.*?)['."'".'"\s\n]/', $header, $matches))
-               $charset = trim(array_pop($matches));
+               $charset = trim(trim(trim(array_pop($matches)), ';,'));
 
        if ($charset == "")
                $charset = "utf-8";
@@ -112,7 +111,12 @@ function parseurl_getsiteinfo($url, $no_guessing = false, $do_oembed = true, $co
        else
                $body = $header;
 
-       $body = mb_convert_encoding($body, "UTF-8", $charset);
+       if (($charset != '') AND (strtoupper($charset) != "UTF-8")) {
+               logger("parseurl_getsiteinfo: detected charset ".$charset, LOGGER_DEBUG);
+               //$body = mb_convert_encoding($body, "UTF-8", $charset);
+               $body = iconv($charset, "UTF-8//TRANSLIT", $body);
+       }
+
        $body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
 
        $doc = new DOMDocument();