]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #950 from thewilli/delete-fix
authorArthurHoaro <arthur@hoa.ro>
Fri, 1 Sep 2017 16:25:44 +0000 (18:25 +0200)
committerGitHub <noreply@github.com>
Fri, 1 Sep 2017 16:25:44 +0000 (18:25 +0200)
fixed link deletion

index.php
tpl/default/js/shaarli.js

index 7210c71fe7811a733b3dde3e851d3eece024febe..07470a0835d46deda2ac29c5d95670cd63714357 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1330,10 +1330,17 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history)
             die('Wrong token.');
         }
 
-        if (strpos($_GET['lf_linkdate'], ' ') !== false) {
-            $ids = array_values(array_filter(preg_split('/\s+/', escape($_GET['lf_linkdate']))));
+        $ids = trim($_GET['lf_linkdate']);
+        if (strpos($ids, ' ') !== false) {
+            // multiple, space-separated ids provided
+            $ids = array_values(array_filter(preg_split('/\s+/', escape($ids))));
         } else {
-            $ids = [$_GET['lf_linkdate']];
+            // only a single id provided
+            $ids = [$ids];
+        }
+        // assert at least one id is given
+        if(!count($ids)){
+            die('no id provided');
         }
         foreach ($ids as $id) {
             $id = (int) escape($id);
index 4f49affa3321226024bae670117d7851ba385141..f38ba62ffdb114e88e2df900836c4f19eeecfd7a 100644 (file)
@@ -401,14 +401,14 @@ window.onload = function () {
 
             var message = 'Are you sure you want to delete '+ links.length +' links?\n';
             message += 'This action is IRREVERSIBLE!\n\nTitles:\n';
-            var ids = '';
+            var ids = [];
             links.forEach(function(item) {
                 message += '  - '+ item['title'] +'\n';
-                ids += item['id'] +'+';
+                ids.push(item['id']);
             });
 
             if (window.confirm(message)) {
-                window.location = '?delete_link&lf_linkdate='+ ids +'&token='+ token.value;
+                window.location = '?delete_link&lf_linkdate='+ ids.join('+') +'&token='+ token.value;
             }
         });
     }