fix: URLs without protocol are now linked to via HTTP
This commit is contained in:
parent
e0a69bbeac
commit
0972606072
|
@ -41,7 +41,7 @@ $tmpl = new OC_Template( 'bookmarks', 'addBm', 'user' );
|
|||
$url = isset($_GET['url']) ? urldecode($_GET['url']) : '';
|
||||
$metadata = getURLMetadata($url);
|
||||
|
||||
$tmpl->assign('URL', htmlentities($url));
|
||||
$tmpl->assign('URL', htmlentities($metadata['url']));
|
||||
$tmpl->assign('TITLE', htmlentities($metadata['title']));
|
||||
$tmpl->assign('DESCRIPTION', htmlentities($metadata['description']));
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ $params=array(
|
|||
$query->execute($params);
|
||||
$b_id = OC_DB::insertid();
|
||||
|
||||
|
||||
if($b_id !== false) {
|
||||
$query = OC_DB::prepare("
|
||||
INSERT INTO *PREFIX*bookmarks_tags
|
||||
|
|
|
@ -7,6 +7,7 @@ function getURLMetadata($url) {
|
|||
if(preg_match($protocols, $url) == 0) {
|
||||
$url = 'http://' . $url;
|
||||
}
|
||||
$metadata['url'] = $url;
|
||||
|
||||
$page = file_get_contents($url);
|
||||
@preg_match( "/<title>(.*)<\/title>/si", $page, $match );
|
||||
|
|
|
@ -50,6 +50,7 @@ function getMetadata() {
|
|||
url: 'ajax/getMeta.php',
|
||||
data: 'url=' + encodeURI(url),
|
||||
success: function(pageinfo){
|
||||
$('#bookmark_add_url').val(pageinfo.data.url);
|
||||
$('#bookmark_add_description').val(pageinfo.data.description);
|
||||
$('#bookmark_add_title').val(pageinfo.data.title);
|
||||
}
|
||||
|
@ -111,6 +112,9 @@ function updateBookmarksList(bookmark) {
|
|||
for ( var i=0, len=tags.length; i<len; ++i ){
|
||||
taglist = taglist + '<a class="bookmark_tags" href="?tag=' + encodeURI(tags[i]) + '">' + tags[i] + '</a> ';
|
||||
}
|
||||
if(!hasProtocol(bookmark.url)) {
|
||||
bookmark.url = 'http://' + bookmark.url;
|
||||
}
|
||||
$('.bookmarks_list').append(
|
||||
'<div class="bookmark_single">' +
|
||||
'<p class="bookmark_title"><a href="' + encodeEntities(bookmark.url) + '" target="_new" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a></p>' +
|
||||
|
@ -144,3 +148,8 @@ function encodeEntities(s){
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function hasProtocol(url) {
|
||||
var regexp = /(ftp|http|https|sftp)/;
|
||||
return regexp.test(url);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue