Skip to content

Commit 8eca0c7

Browse files
authored
Merge pull request #2343 from nextcloud/fix/add-bookmark-without-protocol
fix(BookmarkService): Allow adding bookmarks without protocol
2 parents d71ed20 + feeb798 commit 8eca0c7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

lib/Service/BookmarkService.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private function _addBookmark($userId, $url, ?string $title = null, ?string $des
142142
$testUrl = $this->urlNormalizer->normalize($url);
143143
$data = $this->linkExplorer->get($testUrl);
144144
} else {
145-
// if no allowed protocol is given, evaluate https and https
145+
// if no allowed protocol is given, evaluate https and http
146146
foreach (['https://', 'http://', ''] as $protocol) {
147147
$testUrl = $protocol . $url;
148148
$data = $this->linkExplorer->get($testUrl);
@@ -154,11 +154,12 @@ private function _addBookmark($userId, $url, ?string $title = null, ?string $des
154154
}
155155
}
156156

157+
$url = $data['url'] ?? $url;
157158
if (!preg_match(self::PROTOCOLS_REGEX, $url)) {
158-
throw new UrlParseError();
159+
$url = 'http://' . $url;
159160
}
161+
$url = $this->urlNormalizer->normalize($url);
160162

161-
$url = $data['url'] ?? $url;
162163
$title = $title ?? $data['basic']['title'] ?? $url;
163164
$title = trim($title);
164165
$description = $description ?? $data['basic']['description'] ?? '';

0 commit comments

Comments
 (0)