Merge branch 'main' into develop

pull/184/head
iglocska 2024-09-17 07:57:53 +02:00
commit 1837c4259e
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
2 changed files with 10 additions and 6 deletions

View File

@ -144,9 +144,13 @@ class UserSettingsTable extends AppTable
*/
public function validURI(String $uri): bool
{
try {
$parsed = parse_url($uri);
$isLocalPath = empty($parsed['scheme']) && empty($parsed['domain']) && !empty($parsed['path']);
$isValidURL = !empty($parsed['scheme']) && in_array($parsed['scheme'], ['http', 'https']) && filter_var($uri, FILTER_SANITIZE_URL);
} catch (\Exception $e) {
return false;
}
return $isLocalPath || $isValidURL;
}
}

View File

@ -18,16 +18,16 @@ $this->userSettingsTable = TableRegistry::getTableLocator()->get('UserSettings')
<ul class="col-sm-12 col-md-10 col-l-8 col-xl-8 mb-3">
<?php foreach ($bookmarks as $bookmark) : ?>
<li class="list-group-item">
<?php if ($this->userSettingsTable->validURI($bookmark['url'])): ?>
<?php if (!empty($bookmark['url']) && $this->userSettingsTable->validURI($bookmark['url'])): ?>
<a href="<?= h($bookmark['url']) ?>" class="w-bold">
<?= h($bookmark['label']) ?>
</a>
<?php else: ?>
<span class="w-bold">
<?= h($bookmark['url']) ?>
<?= !empty($bookmark['url']) ? h($bookmark['url']) : '' ?>
</span>
<?php endif; ?>
<span class="ms-3 fw-light"><?= h($bookmark['name']) ?></span>
<span class="ms-3 fw-light"><?= !empty($bookmark['name']) ? h($bookmark['name']): '' ?></span>
</li>
<?php endforeach; ?>
</ul>