summaryrefslogtreecommitdiffstats
path: root/apps/bookmarks
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2011-08-25 13:23:52 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2011-08-25 13:23:52 +0200
commit097260607255ebe10aae7f64a53a5f7faabe7c1d (patch)
treee6630ba9c853c2643c2b4ee6c89a33fc279406cd /apps/bookmarks
parente0a69bbeaccf45ec6f407090d3dfc50bc4f04101 (diff)
downloadnextcloud-server-097260607255ebe10aae7f64a53a5f7faabe7c1d.tar.gz
nextcloud-server-097260607255ebe10aae7f64a53a5f7faabe7c1d.zip
fix: URLs without protocol are now linked to via HTTP
Diffstat (limited to 'apps/bookmarks')
-rw-r--r--apps/bookmarks/addBm.php2
-rw-r--r--apps/bookmarks/ajax/addBookmark.php1
-rw-r--r--apps/bookmarks/bookmarksHelper.php1
-rw-r--r--apps/bookmarks/js/bookmarks.js11
4 files changed, 12 insertions, 3 deletions
diff --git a/apps/bookmarks/addBm.php b/apps/bookmarks/addBm.php
index d308e8fe605..2dab33afb22 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 d3d23aad267..d066b0b32ff 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 be6ac098d0f..383a8ddd565 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>(.*)<\/title>/si", $page, $match );
diff --git a/apps/bookmarks/js/bookmarks.js b/apps/bookmarks/js/bookmarks.js
index 93b21c3243e..760ae96b9e6 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);
+}