diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-03-23 18:31:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-23 18:31:40 +0100 |
commit | 4296080c8e0bc0576564bfb52bfe2cbc94fafed3 (patch) | |
tree | 9d90d171445aafe97f82fdbf9f19b4fc32e2f484 /index.php | |
parent | c84379478621303b186f50d647e90079727b6062 (diff) | |
parent | b712ab0ac4df2638323bc3d5b7d22341bf3abb56 (diff) | |
download | Shaarli-4296080c8e0bc0576564bfb52bfe2cbc94fafed3.tar.gz Shaarli-4296080c8e0bc0576564bfb52bfe2cbc94fafed3.tar.zst Shaarli-4296080c8e0bc0576564bfb52bfe2cbc94fafed3.zip |
Merge pull request #829 from ArthurHoaro/hotfix/id-0
Fixes a bug preventing to edit link with ID 0
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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']; |