1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2025-01-31 01:52:11 +01:00

Add Some protection and take title from bookmarklet when possible

This commit is contained in:
Brice Maron 2012-06-27 10:15:20 +02:00
parent a5651c6ba2
commit 150f2a3f27
2 changed files with 11 additions and 4 deletions

View File

@ -38,7 +38,8 @@ if(!isset($_GET['url']) || trim($_GET['url']) == '') {
$tmpl->printPage();
exit;
}elseif(isset($_POST['url'])) {
$bm = addBookmark($_POST['url'], $_POST['title'], implode(' ',$_POST['item']['tags']),$_POST['desc'], $_POST['is_public']);
$tags = isset($_POST['item']['tags']) ? $_POST['item']['tags'] : array();
$bm = addBookmark($_POST['url'], $_POST['title'], implode(' ',$tags),$_POST['desc'], $_POST['is_public']);
OCP\JSON::success(array('id'=>$bm));
exit();
}
@ -48,9 +49,15 @@ OCP\Util::addscript('bookmarks','addBm');
OCP\Util::addStyle('bookmarks', 'bookmarks');
OCP\Util::addStyle('bookmarks', 'jquery.tagit');
$datas = getURLMetadata($_GET['url']);
if(!isset($_GET['title']) || trim($_GET['title']) == '') {
$datas = getURLMetadata($_GET['url']);
$title = isset($datas['title']) ? $datas['title'] : '';
}
else{
$title = $_GET['title'];
}
$bm = array('title'=> $datas['title'] ? $datas['title'] : '' ,
$bm = array('title'=> $title,
'url'=> $_GET['url'],
'tags'=> array(),
'desc'=>'',

View File

@ -3,6 +3,6 @@
function createBookmarklet() {
$l = OC_L10N::get('bookmarks');
echo '<small>' . $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:') . '</small>'
. '<a class="button bookmarklet" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open(\'' . OCP\Util::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location),\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=400px,width=550px,resizable=1,alwaysRaised=1\');a.setTimeout(function(){d.focus()},300);})();">'
. '<a class="button bookmarklet" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,e=document.getElementsByTagName(\'title\')[0].textContent,d=a.open(\'' . OCP\Util::linkToAbsolute('bookmarks', 'addBm.php') . '?output=popup&url=\'+c(b.location)+\'&title=\'+e,\'bkmk_popup\',\'left=\'+((a.screenX||a.screenLeft)+10)+\',top=\'+((a.screenY||a.screenTop)+10)+\',height=400px,width=550px,resizable=1,alwaysRaised=1\');a.setTimeout(function(){d.focus()},300);})();">'
. $l->t('Read later') . '</a>';
}