Ensure that the baseurl return value is a string
authorMichael <heluecht@pirati.ca>
Thu, 11 May 2023 08:13:19 +0000 (08:13 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 11 May 2023 08:13:19 +0000 (08:13 +0000)
12 files changed:
mod/message.php
src/Content/Smilies.php
src/Model/Photo.php
src/Model/User.php
src/Module/HCard.php
src/Module/OpenSearch.php
src/Module/Register.php
src/Module/WellKnown/HostMeta.php
src/Protocol/ActivityPub/Transmitter.php
view/theme/frio/php/default.php
view/theme/smoothly/theme.php
view/theme/vier/theme.php

index 928f575..d75fb24 100644 (file)
@@ -54,11 +54,10 @@ function message_init(App $a)
                '$tabs' => $tabs,
                '$new'  => $new,
        ]);
-       $base = DI::baseUrl();
 
        $head_tpl = Renderer::getMarkupTemplate('message-head.tpl');
        DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [
-               '$base'    => $base
+               '$base' => (string)DI::baseUrl()
        ]);
 }
 
index ff9d638..d231797 100644 (file)
@@ -106,7 +106,7 @@ class Smilies
 
                ];
 
-               $baseUrl = DI::baseUrl();
+               $baseUrl = (string)DI::baseUrl();
 
                $icons = [
                '<img class="smiley" src="' . $baseUrl . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />',
index 74031a8..1b87e82 100644 (file)
@@ -918,9 +918,7 @@ class Photo
         */
        public static function getResourceData(string $name): array
        {
-               $base = DI::baseUrl();
-
-               $guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name));
+               $guid = str_replace([Strings::normaliseLink((string)DI::baseUrl()), '/photo/'], '', Strings::normaliseLink($name));
 
                if (parse_url($guid, PHP_URL_SCHEME)) {
                        return [];
@@ -982,9 +980,7 @@ class Photo
         */
        public static function isLocalPage(string $name): bool
        {
-               $base = DI::baseUrl();
-
-               $guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name));
+               $guid = str_replace(Strings::normaliseLink((string)DI::baseUrl()), '', Strings::normaliseLink($name));
                $guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);
                if (empty($guid)) {
                        return false;
index 11d55e7..3be13be 100644 (file)
@@ -167,7 +167,7 @@ class User
                $system['region'] = '';
                $system['postal-code'] = '';
                $system['country-name'] = '';
-               $system['homepage'] = DI::baseUrl();
+               $system['homepage'] = (string)DI::baseUrl();
                $system['dob'] = '0000-00-00';
 
                // Ensure that the user contains data
index 9262712..ce63d77 100644 (file)
@@ -64,9 +64,9 @@ class HCard extends BaseModule
                        $page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n";
                }
 
-               $baseUrl = DI::baseUrl();
+               $baseUrl = (string)DI::baseUrl();
 
-               $uri = urlencode('acct:' . $profile['nickname'] . '@' . $baseUrl->getHost() . ($baseUrl->getPath() ? '/' . $baseUrl->getPath() : ''));
+               $uri = urlencode('acct:' . $profile['nickname'] . '@' . DI::baseUrl()->getHost() . (DI::baseUrl()->getPath() ? '/' . DI::baseUrl()->getPath() : ''));
 
                $page['htmlhead'] .= '<meta name="dfrn-global-visibility" content="' . ($profile['net-publish'] ? 'true' : 'false') . '" />' . "\r\n";
                $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/dfrn_poll/' . $nickname . '" />' . "\r\n";
index f01baaf..7c44bc5 100644 (file)
@@ -40,7 +40,7 @@ class OpenSearch extends BaseModule
        protected function rawContent(array $request = [])
        {
                $hostname = DI::baseUrl()->getHost();
-               $baseUrl  = DI::baseUrl();
+               $baseUrl  = (string)DI::baseUrl();
 
                /** @var DOMDocument $xml */
                XML::fromArray([
index e5c5840..d26fb0a 100644 (file)
@@ -298,7 +298,7 @@ class Register extends BaseModule
 
                $user = $result['user'];
 
-               $base_url = DI::baseUrl();
+               $base_url = (string)DI::baseUrl();
 
                if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) {
                        $url = $base_url . '/profile/' . $user['nickname'];
index 75976ac..eadc9f2 100644 (file)
@@ -46,7 +46,7 @@ class HostMeta extends BaseModule
                        $config->set('system', 'site_pubkey', $res['pubkey']);
                }
 
-               $domain = DI::baseUrl();
+               $domain = (string)DI::baseUrl();
 
                XML::fromArray([
                        'XRD' => [
index c24c29f..3d94518 100644 (file)
@@ -330,7 +330,7 @@ class Transmitter
                return [
                        'type' => 'Service',
                        'name' =>  App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION,
-                       'url' => DI::baseUrl()
+                       'url' => (string)DI::baseUrl()
                ];
        }
 
index 0677ff9..a75207a 100644 (file)
@@ -45,7 +45,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser";
        <head>
                <title><?php if (!empty($page['title'])) echo $page['title'] ?></title>
                <meta request="<?php echo htmlspecialchars($_REQUEST['pagename'] ?? '') ?>">
-               <script  type="text/javascript">var baseurl = "<?php echo DI::baseUrl(); ?>";</script>
+               <script  type="text/javascript">var baseurl = "<?php echo (string)DI::baseUrl(); ?>";</script>
                <script type="text/javascript">var frio = "<?php echo 'view/theme/frio'; ?>";</script>
 <?php
                // Because we use minimal for modals the header and the included js stuff should be only loaded
index f56aa30..73ff814 100644 (file)
@@ -45,7 +45,7 @@ function smoothly_init(App $a) {
 
        $cssFile = null;
        $ssl_state = false;
-       $baseurl = DI::baseUrl();
+       $baseurl = (string)DI::baseUrl();
        DI::page()['htmlhead'] .= <<< EOT
 
 <script>
@@ -112,7 +112,7 @@ if (! function_exists('_js_in_foot')) {
                /** @purpose insert stuff in bottom of page
                */
                $ssl_state = false;
-               $baseurl = DI::baseUrl();
+               $baseurl = (string)DI::baseUrl();
                $bottom['$baseurl'] = $baseurl;
                $tpl = Renderer::getMarkupTemplate('bottom.tpl');
 
index 91e050c..95cc9bb 100644 (file)
@@ -137,8 +137,7 @@ function vier_community_info()
        $show_lastusers  = get_vier_config("show_lastusers", 1);
 
        // get_baseurl
-       $url = DI::baseUrl();
-       $aside['$url'] = $url;
+       $aside['$url'] = $url = (string)DI::baseUrl();
 
        // community_profiles
        if ($show_profiles) {