Merge pull request #829 from ArthurHoaro/hotfix/id-0

Fixes a bug preventing to edit link with ID 0
This commit is contained in:
ArthurHoaro 2017-03-23 18:31:40 +01:00 committed by GitHub
commit 4296080c8e

View file

@ -1245,7 +1245,7 @@ function renderPage($conf, $pluginManager, $LINKSDB)
} }
// lf_id should only be present if the link exists. // lf_id should only be present if the link exists.
$id = !empty($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : $LINKSDB->getNextId(); $id = isset($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : $LINKSDB->getNextId();
// Linkdate is kept here to: // Linkdate is kept here to:
// - use the same permalink for notes as they're displayed when creating them // - use the same permalink for notes as they're displayed when creating them
// - let users hack creation date of their posts // - let users hack creation date of their posts
@ -1318,9 +1318,13 @@ function renderPage($conf, $pluginManager, $LINKSDB)
// -------- User clicked the "Cancel" button when editing a link. // -------- User clicked the "Cancel" button when editing a link.
if (isset($_POST['cancel_edit'])) if (isset($_POST['cancel_edit']))
{ {
$id = isset($_POST['lf_id']) ? (int) escape($_POST['lf_id']) : false;
if (! isset($LINKSDB[$id])) {
header('Location: ?');
}
// If we are called from the bookmarklet, we must close the popup: // If we are called from the bookmarklet, we must close the popup:
if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
$link = $LINKSDB[(int) escape($_POST['lf_id'])]; $link = $LINKSDB[$id];
$returnurl = ( isset($_POST['returnurl']) ? $_POST['returnurl'] : '?' ); $returnurl = ( isset($_POST['returnurl']) ? $_POST['returnurl'] : '?' );
// Scroll to the link which has been edited. // Scroll to the link which has been edited.
$returnurl .= '#'. $link['shorturl']; $returnurl .= '#'. $link['shorturl'];