aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-03-22 19:08:17 +0100
committerArthurHoaro <arthur@hoa.ro>2017-03-22 19:08:17 +0100
commitb712ab0ac4df2638323bc3d5b7d22341bf3abb56 (patch)
tree9d90d171445aafe97f82fdbf9f19b4fc32e2f484
parentc84379478621303b186f50d647e90079727b6062 (diff)
downloadShaarli-b712ab0ac4df2638323bc3d5b7d22341bf3abb56.tar.gz
Shaarli-b712ab0ac4df2638323bc3d5b7d22341bf3abb56.tar.zst
Shaarli-b712ab0ac4df2638323bc3d5b7d22341bf3abb56.zip
Fixes a bug preventing to edit link with ID 0
Fixes #814
-rw-r--r--index.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/index.php b/index.php
index cf85197a..bf312d55 100644
--- a/index.php
+++ b/index.php
@@ -1245,7 +1245,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1245 } 1245 }
1246 1246
1247 // lf_id should only be present if the link exists. 1247 // lf_id should only be present if the link exists.
1248 $id = !empty($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : $LINKSDB->getNextId(); 1248 $id = isset($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : $LINKSDB->getNextId();
1249 // Linkdate is kept here to: 1249 // Linkdate is kept here to:
1250 // - use the same permalink for notes as they're displayed when creating them 1250 // - use the same permalink for notes as they're displayed when creating them
1251 // - let users hack creation date of their posts 1251 // - let users hack creation date of their posts
@@ -1318,9 +1318,13 @@ function renderPage($conf, $pluginManager, $LINKSDB)
1318 // -------- User clicked the "Cancel" button when editing a link. 1318 // -------- User clicked the "Cancel" button when editing a link.
1319 if (isset($_POST['cancel_edit'])) 1319 if (isset($_POST['cancel_edit']))
1320 { 1320 {
1321 $id = isset($_POST['lf_id']) ? (int) escape($_POST['lf_id']) : false;
1322 if (! isset($LINKSDB[$id])) {
1323 header('Location: ?');
1324 }
1321 // If we are called from the bookmarklet, we must close the popup: 1325 // If we are called from the bookmarklet, we must close the popup:
1322 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } 1326 if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
1323 $link = $LINKSDB[(int) escape($_POST['lf_id'])]; 1327 $link = $LINKSDB[$id];
1324 $returnurl = ( isset($_POST['returnurl']) ? $_POST['returnurl'] : '?' ); 1328 $returnurl = ( isset($_POST['returnurl']) ? $_POST['returnurl'] : '?' );
1325 // Scroll to the link which has been edited. 1329 // Scroll to the link which has been edited.
1326 $returnurl .= '#'. $link['shorturl']; 1330 $returnurl .= '#'. $link['shorturl'];