- // Remove multiple spaces.
- $tags = trim(preg_replace('/\s\s+/', ' ', $_POST['lf_tags']));
- // Remove first '-' char in tags.
- $tags = preg_replace('/(^| )\-/', '$1', $tags);
- // Remove duplicates.
- $tags = implode(' ', array_unique(explode(' ', $tags)));
-
- if (empty(trim($_POST['lf_url']))) {
- $_POST['lf_url'] = '?' . smallHash($linkdate . $id);
- }
- $url = whitelist_protocols(trim($_POST['lf_url']), $conf->get('security.allowed_protocols'));
-
- $link = array_merge($link, [
- 'title' => trim($_POST['lf_title']),
- 'url' => $url,
- 'description' => $_POST['lf_description'],
- 'private' => (isset($_POST['lf_private']) ? 1 : 0),
- 'tags' => str_replace(',', ' ', $tags),
- ]);
-
- // If title is empty, use the URL as title.
- if ($link['title'] == '') {
- $link['title'] = $link['url'];
- }
+ $bookmark->setTitle($_POST['lf_title']);
+ $bookmark->setDescription($_POST['lf_description']);
+ $bookmark->setUrl($_POST['lf_url'], $conf->get('security.allowed_protocols'));
+ $bookmark->setPrivate(isset($_POST['lf_private']));
+ $bookmark->setTagsString($_POST['lf_tags']);