Ensure that the baseurl return value is a string

This commit is contained in:
Michael 2023-05-11 08:13:19 +00:00
parent 4c40bc164d
commit e13a31c4fe
12 changed files with 15 additions and 21 deletions

View file

@ -54,11 +54,10 @@ function message_init(App $a)
'$tabs' => $tabs, '$tabs' => $tabs,
'$new' => $new, '$new' => $new,
]); ]);
$base = DI::baseUrl();
$head_tpl = Renderer::getMarkupTemplate('message-head.tpl'); $head_tpl = Renderer::getMarkupTemplate('message-head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [ DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [
'$base' => $base '$base' => (string)DI::baseUrl()
]); ]);
} }

View file

@ -106,7 +106,7 @@ class Smilies
]; ];
$baseUrl = DI::baseUrl(); $baseUrl = (string)DI::baseUrl();
$icons = [ $icons = [
'<img class="smiley" src="' . $baseUrl . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />', '<img class="smiley" src="' . $baseUrl . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />',

View file

@ -918,9 +918,7 @@ class Photo
*/ */
public static function getResourceData(string $name): array public static function getResourceData(string $name): array
{ {
$base = DI::baseUrl(); $guid = str_replace([Strings::normaliseLink((string)DI::baseUrl()), '/photo/'], '', Strings::normaliseLink($name));
$guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name));
if (parse_url($guid, PHP_URL_SCHEME)) { if (parse_url($guid, PHP_URL_SCHEME)) {
return []; return [];
@ -982,9 +980,7 @@ class Photo
*/ */
public static function isLocalPage(string $name): bool public static function isLocalPage(string $name): bool
{ {
$base = DI::baseUrl(); $guid = str_replace(Strings::normaliseLink((string)DI::baseUrl()), '', Strings::normaliseLink($name));
$guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name));
$guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid); $guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);
if (empty($guid)) { if (empty($guid)) {
return false; return false;

View file

@ -167,7 +167,7 @@ class User
$system['region'] = ''; $system['region'] = '';
$system['postal-code'] = ''; $system['postal-code'] = '';
$system['country-name'] = ''; $system['country-name'] = '';
$system['homepage'] = DI::baseUrl(); $system['homepage'] = (string)DI::baseUrl();
$system['dob'] = '0000-00-00'; $system['dob'] = '0000-00-00';
// Ensure that the user contains data // Ensure that the user contains data

View file

@ -64,9 +64,9 @@ class HCard extends BaseModule
$page['htmlhead'] .= '<link rel="openid.delegate" href="' . $delegate . '" />' . "\r\n"; $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'] .= '<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"; $page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $baseUrl . '/dfrn_poll/' . $nickname . '" />' . "\r\n";

View file

@ -40,7 +40,7 @@ class OpenSearch extends BaseModule
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
$hostname = DI::baseUrl()->getHost(); $hostname = DI::baseUrl()->getHost();
$baseUrl = DI::baseUrl(); $baseUrl = (string)DI::baseUrl();
/** @var DOMDocument $xml */ /** @var DOMDocument $xml */
XML::fromArray([ XML::fromArray([

View file

@ -298,7 +298,7 @@ class Register extends BaseModule
$user = $result['user']; $user = $result['user'];
$base_url = DI::baseUrl(); $base_url = (string)DI::baseUrl();
if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) { if ($netpublish && intval(DI::config()->get('config', 'register_policy')) !== self::APPROVE) {
$url = $base_url . '/profile/' . $user['nickname']; $url = $base_url . '/profile/' . $user['nickname'];

View file

@ -46,7 +46,7 @@ class HostMeta extends BaseModule
$config->set('system', 'site_pubkey', $res['pubkey']); $config->set('system', 'site_pubkey', $res['pubkey']);
} }
$domain = DI::baseUrl(); $domain = (string)DI::baseUrl();
XML::fromArray([ XML::fromArray([
'XRD' => [ 'XRD' => [

View file

@ -330,7 +330,7 @@ class Transmitter
return [ return [
'type' => 'Service', 'type' => 'Service',
'name' => App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION, 'name' => App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION,
'url' => DI::baseUrl() 'url' => (string)DI::baseUrl()
]; ];
} }

View file

@ -45,7 +45,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser";
<head> <head>
<title><?php if (!empty($page['title'])) echo $page['title'] ?></title> <title><?php if (!empty($page['title'])) echo $page['title'] ?></title>
<meta request="<?php echo htmlspecialchars($_REQUEST['pagename'] ?? '') ?>"> <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> <script type="text/javascript">var frio = "<?php echo 'view/theme/frio'; ?>";</script>
<?php <?php
// Because we use minimal for modals the header and the included js stuff should be only loaded // Because we use minimal for modals the header and the included js stuff should be only loaded

View file

@ -45,7 +45,7 @@ function smoothly_init(App $a) {
$cssFile = null; $cssFile = null;
$ssl_state = false; $ssl_state = false;
$baseurl = DI::baseUrl(); $baseurl = (string)DI::baseUrl();
DI::page()['htmlhead'] .= <<< EOT DI::page()['htmlhead'] .= <<< EOT
<script> <script>
@ -112,7 +112,7 @@ if (! function_exists('_js_in_foot')) {
/** @purpose insert stuff in bottom of page /** @purpose insert stuff in bottom of page
*/ */
$ssl_state = false; $ssl_state = false;
$baseurl = DI::baseUrl(); $baseurl = (string)DI::baseUrl();
$bottom['$baseurl'] = $baseurl; $bottom['$baseurl'] = $baseurl;
$tpl = Renderer::getMarkupTemplate('bottom.tpl'); $tpl = Renderer::getMarkupTemplate('bottom.tpl');

View file

@ -137,8 +137,7 @@ function vier_community_info()
$show_lastusers = get_vier_config("show_lastusers", 1); $show_lastusers = get_vier_config("show_lastusers", 1);
// get_baseurl // get_baseurl
$url = DI::baseUrl(); $aside['$url'] = $url = (string)DI::baseUrl();
$aside['$url'] = $url;
// community_profiles // community_profiles
if ($show_profiles) { if ($show_profiles) {