]> git.mxchange.org Git - friendica.git/blobdiff - mod/parse_url.php
Merge pull request #6324 from MrPetovan/bug/6316-remove-html-encode
[friendica.git] / mod / parse_url.php
index 40eddc3bdd5053afcd93e1581048d4f13f9baf1f..07f319fdca69e8ab2372b29b1302a81d1c97398c 100644 (file)
@@ -11,6 +11,7 @@
  */
 use Friendica\App;
 use Friendica\Core\Addon;
+use Friendica\Core\Logger;
 use Friendica\Util\Network;
 use Friendica\Util\ParseUrl;
 
@@ -46,15 +47,15 @@ function parse_url_content(App $a)
 
        // Add url scheme if it is missing
        $arrurl = parse_url($url);
-       if (!x($arrurl, 'scheme')) {
-               if (x($arrurl, 'host')) {
+       if (empty($arrurl['scheme'])) {
+               if (!empty($arrurl['host'])) {
                        $url = 'http:' . $url;
                } else {
                        $url = 'http://' . $url;
                }
        }
 
-       logger($url);
+       Logger::log($url);
 
        // Check if the URL is an image, video or audio file. If so format
        // the URL with the corresponding BBCode media tag
@@ -73,6 +74,7 @@ function parse_url_content(App $a)
                                $hdrs[$k] = $v;
                        }
                }
+               $type = null;
                if (array_key_exists('Content-Type', $hdrs)) {
                        $type = $hdrs['Content-Type'];
                }
@@ -92,6 +94,7 @@ function parse_url_content(App $a)
                }
        }
 
+
        $template = '[bookmark=%s]%s[/bookmark]%s';
 
        $arr = ['url' => $url, 'text' => ''];
@@ -112,7 +115,7 @@ function parse_url_content(App $a)
 
                $result = sprintf($template, $url, ($title) ? $title : $url, $text) . $str_tags;
 
-               logger('(unparsed): returns: ' . $result);
+               Logger::log('(unparsed): returns: ' . $result);
 
                echo $result;
                exit();
@@ -123,6 +126,12 @@ function parse_url_content(App $a)
 
        unset($siteinfo['keywords']);
 
+       // Bypass attachment if parse url for a comment
+       if (!empty($_GET['noAttachment'])) {
+               echo $br . '[url=' . $url . ']' . $siteinfo['title'] . '[/url]';
+               exit();
+       }
+
        // Format it as BBCode attachment
        $info = add_page_info_data($siteinfo);