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..78913f7a13 100644 --- a/apps/bookmarks/ajax/addBookmark.php +++ b/apps/bookmarks/ajax/addBookmark.php @@ -51,15 +51,14 @@ $query = OC_DB::prepare(" $params=array( - urldecode($_GET["url"]), - urldecode($_GET["title"]), - urldecode($_GET["description"]), + htmlspecialchars_decode($_GET["url"]), + htmlspecialchars_decode($_GET["title"]), + htmlspecialchars_decode($_GET["description"]), OC_User::getUser() ); $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/ajax/delBookmark.php b/apps/bookmarks/ajax/delBookmark.php index 99a618a7d1..bf1611fe5c 100644 --- a/apps/bookmarks/ajax/delBookmark.php +++ b/apps/bookmarks/ajax/delBookmark.php @@ -36,7 +36,7 @@ if( !OC_User::isLoggedIn()){ } $params=array( - urldecode($_GET["url"]), + htmlspecialchars_decode($_GET["url"]), OC_User::getUser() ); diff --git a/apps/bookmarks/ajax/getMeta.php b/apps/bookmarks/ajax/getMeta.php index dadf23afd9..e9fe0d684d 100644 --- a/apps/bookmarks/ajax/getMeta.php +++ b/apps/bookmarks/ajax/getMeta.php @@ -38,7 +38,7 @@ if( !OC_User::isLoggedIn()){ // $metadata = array(); require '../bookmarksHelper.php'; +$metadata = getURLMetadata(htmlspecialchars_decode($_GET["url"])); -$metadata = getURLMetadata(urldecode($_GET["url"])); echo json_encode( array( 'status' => 'success', 'data' => $metadata)); diff --git a/apps/bookmarks/ajax/recordClick.php b/apps/bookmarks/ajax/recordClick.php index 4dcb0b4a0d..116daea8bb 100644 --- a/apps/bookmarks/ajax/recordClick.php +++ b/apps/bookmarks/ajax/recordClick.php @@ -40,7 +40,7 @@ $query = OC_DB::prepare(" AND url LIKE ? "); -$params=array(OC_User::getUser(), urldecode($_GET["url"])); +$params=array(OC_User::getUser(), htmlspecialchars_decode($_GET["url"])); $bookmarks = $query->execute($params); header( "HTTP/1.1 204 No Content" ); diff --git a/apps/bookmarks/ajax/updateList.php b/apps/bookmarks/ajax/updateList.php index 9290757d0b..ceecc5b7ef 100644 --- a/apps/bookmarks/ajax/updateList.php +++ b/apps/bookmarks/ajax/updateList.php @@ -39,7 +39,7 @@ $params=array(OC_User::getUser()); $CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' ); //Filter for tag? -$filterTag = isset($_GET['tag']) ? '%' . urldecode($_GET['tag']) . '%' : false; +$filterTag = isset($_GET['tag']) ? '%' . htmlspecialchars_decode($_GET['tag']) . '%' : false; if($filterTag){ $sqlFilterTag = 'HAVING tags LIKE ?'; $params[] = $filterTag; @@ -50,6 +50,13 @@ if($filterTag){ $offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0; $params[] = $offset; +$sort = isset($_GET['sort']) ? ($_GET['sort']) : 'bookmarks_sorting_recent'; +if($sort == 'bookmarks_sorting_clicks') { + $sqlSort = 'clickcount DESC'; +} else { + $sqlSort = 'id DESC'; +} + if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ $_gc_separator = ', \' \''; } else { @@ -72,7 +79,7 @@ $query = OC_DB::prepare(' AND *PREFIX*bookmarks.user_id = ? GROUP BY url '.$sqlFilterTag.' - ORDER BY *PREFIX*bookmarks.id DESC + ORDER BY *PREFIX*bookmarks.'.$sqlSort.' LIMIT ?, 10'); $bookmarks = $query->execute($params)->fetchAll(); diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php index be6ac098d0..aee941a27b 100644 --- a/apps/bookmarks/bookmarksHelper.php +++ b/apps/bookmarks/bookmarksHelper.php @@ -7,10 +7,11 @@ function getURLMetadata($url) { if(preg_match($protocols, $url) == 0) { $url = 'http://' . $url; } + $metadata['url'] = $url; $page = file_get_contents($url); @preg_match( "/
' + encodeEntities(bookmark.title) + '
' + @@ -127,3 +148,8 @@ function encodeEntities(s){ return ""; } } + +function hasProtocol(url) { + var regexp = /(ftp|http|https|sftp)/; + return regexp.test(url); +} diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php index d7d37257a8..4f101d44f9 100644 --- a/apps/bookmarks/templates/list.php +++ b/apps/bookmarks/templates/list.php @@ -1,8 +1,8 @@