]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Profile/Profile.php
Merge pull request #12962 from annando/issue-12876c
[friendica.git] / src / Module / Profile / Profile.php
index bed5ffce7ffea1b49c0486a295c21d683fbc0ded..d753cd762ea004509cc936d1a4fb874ccd3e9877 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -26,7 +26,6 @@ use Friendica\Content\Feature;
 use Friendica\Content\ForumManager;
 use Friendica\Content\Nav;
 use Friendica\Content\Text\BBCode;
-use Friendica\Content\Text\HTML;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
@@ -48,6 +47,7 @@ use Friendica\Profile\ProfileField\Repository\ProfileField;
 use Friendica\Protocol\ActivityPub;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Profiler;
+use Friendica\Util\Strings;
 use Friendica\Util\Temporal;
 use Psr\Log\LoggerInterface;
 
@@ -204,7 +204,11 @@ class Profile extends BaseProfile
                }
 
                if ($profile['homepage']) {
-                       $basic_fields += self::buildField('homepage', $this->t('Homepage:'), HTML::toLink($profile['homepage']));
+                       $basic_fields += self::buildField(
+                               'homepage',
+                               $this->t('Homepage:'),
+                               $this->tryRelMe($profile['homepage']) ?: $profile['homepage']
+                       );
                }
 
                if (
@@ -245,12 +249,12 @@ class Profile extends BaseProfile
                        $custom_fields += self::buildField(
                                'custom_' . $profile_field->order,
                                $profile_field->label,
-                               BBCode::convertForUriId($profile['uri-id'], $profile_field->value),
+                               $this->tryRelMe($profile_field->value) ?: BBCode::convertForUriId($profile['uri-id'], $profile_field->value),
                                'aprofile custom'
                        );
                }
 
-               //show subcribed forum if it is enabled in the usersettings
+               //show subscribed forum if it is enabled in the usersettings
                if (Feature::isEnabled($profile['uid'], 'forumlist_profile')) {
                        $custom_fields += self::buildField(
                                'forumlist',
@@ -348,7 +352,7 @@ class Profile extends BaseProfile
                $htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/" title="' . $this->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
                $htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/comments" title="' . $this->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
                $htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/activity" title="' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
-               $uri      = urlencode('acct:' . $profile['nickname'] . '@' . $this->baseUrl->getHostname() . ($this->baseUrl->getUrlPath() ? '/' . $this->baseUrl->getUrlPath() : ''));
+               $uri      = urlencode('acct:' . $profile['nickname'] . '@' . $this->baseUrl->getHost() . ($this->baseUrl->getPath() ? '/' . $this->baseUrl->getPath() : ''));
                $htmlhead .= '<link rel="lrdd" type="application/xrd+xml" href="' . $this->baseUrl . '/xrd/?uri=' . $uri . '" />' . "\n";
                header('Link: <' . $this->baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
 
@@ -359,4 +363,19 @@ class Profile extends BaseProfile
 
                return $htmlhead;
        }
+
+       /**
+        * Check if the input is an HTTP(S) link and returns a rel="me" link if yes, empty string if not
+        *
+        * @param string $input
+        * @return string
+        */
+       private function tryRelMe(string $input): string
+       {
+               if (preg_match(Strings::onlyLinkRegEx(), trim($input))) {
+                       return '<a href="' . trim($input) . '" target="_blank" rel="noopener noreferrer me">' . trim($input) . '</a>';
+               }
+
+               return '';
+       }
 }