mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-02-08 07:54:13 +01:00
Merge pull request #245 from owncloud/dont-overrride-title
Do not override user-provided title when bookmarking via bookmarklet
This commit is contained in:
commit
ff6e1f48a4
@ -72,25 +72,25 @@ class BookmarkController extends ApiController {
|
|||||||
// allow only http(s) and (s)ftp
|
// allow only http(s) and (s)ftp
|
||||||
$protocols = '/^(https?|s?ftp)\:\/\//i';
|
$protocols = '/^(https?|s?ftp)\:\/\//i';
|
||||||
if (preg_match($protocols, $url)) {
|
if (preg_match($protocols, $url)) {
|
||||||
$datas = Bookmarks::getURLMetadata($url);
|
$data = Bookmarks::getURLMetadata($url);
|
||||||
// if not (allowed) protocol is given, assume http and https (and fetch both)
|
// if not (allowed) protocol is given, assume http and https (and fetch both)
|
||||||
} else {
|
} else {
|
||||||
// append https to url and fetch it
|
// append https to url and fetch it
|
||||||
$url_https = 'https://' . $url;
|
$url_https = 'https://' . $url;
|
||||||
$datas_https = Bookmarks::getURLMetadata($url_https);
|
$data_https = Bookmarks::getURLMetadata($url_https);
|
||||||
// append http to url and fetch it
|
// append http to url and fetch it
|
||||||
$url_http = 'http://' . $url;
|
$url_http = 'http://' . $url;
|
||||||
$datas_http = Bookmarks::getURLMetadata($url_http);
|
$data_http = Bookmarks::getURLMetadata($url_http);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($datas['title'])) { // prefer original url if working
|
if ($title === '' && isset($data['title'])) { // prefer original url if working
|
||||||
$title = $datas['title'];
|
$title = $data['title'];
|
||||||
//url remains unchanged
|
//url remains unchanged
|
||||||
} elseif (isset($datas_https['title'])) { // test if https works
|
} elseif (isset($data_https['title'])) { // test if https works
|
||||||
$title = $datas_https['title'];
|
$title = $title === '' ? $data_https['title'] : $title;
|
||||||
$url = $url_https;
|
$url = $url_https;
|
||||||
} elseif (isset($datas_http['title'])) { // otherwise test http for results
|
} elseif (isset($data_http['title'])) { // otherwise test http for results
|
||||||
$title = $datas_http['title'];
|
$title = $title === '' ? $data_http['title'] : $title;
|
||||||
$url = $url_http;
|
$url = $url_http;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user