diff --git a/apps/bookmarks/addBm.php b/apps/bookmarks/addBm.php index d308e8fe60..2dab33afb2 100644 --- a/apps/bookmarks/addBm.php +++ b/apps/bookmarks/addBm.php @@ -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'])); diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php index d3d23aad26..d066b0b32f 100644 --- a/apps/bookmarks/ajax/addBookmark.php +++ b/apps/bookmarks/ajax/addBookmark.php @@ -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 diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php index be6ac098d0..383a8ddd56 100644 --- a/apps/bookmarks/bookmarksHelper.php +++ b/apps/bookmarks/bookmarksHelper.php @@ -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>/si", $page, $match ); diff --git a/apps/bookmarks/js/bookmarks.js b/apps/bookmarks/js/bookmarks.js index 93b21c3243..760ae96b9e 100644 --- a/apps/bookmarks/js/bookmarks.js +++ b/apps/bookmarks/js/bookmarks.js @@ -49,7 +49,8 @@ function getMetadata() { $.ajax({ url: 'ajax/getMeta.php', data: 'url=' + encodeURI(url), - success: function(pageinfo){ + 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); +}