# HG changeset patch
# User Sebastian Hengst <archaeopteryx@coole-files.de>
# Date 1456474890 -3600
#      Fri Feb 26 09:21:30 2016 +0100
# Branch THUNDERBIRD3880_2016050308_RELBRANCH
# Node ID f4320da62b7b610e0d337df47ae107c09856cd08
# Parent  bf301f651d4b3696c5cc9deebc01383745076e1e
Bug 1249153 - drag and drop of contacts from list onto addressbook while All Addressbooks is selected shouldn't move only one and duplicate it. r=aceman a=rkent

diff --git a/mailnews/addrbook/content/abDragDrop.js b/mailnews/addrbook/content/abDragDrop.js
--- a/mailnews/addrbook/content/abDragDrop.js
+++ b/mailnews/addrbook/content/abDragDrop.js
@@ -223,17 +223,17 @@
         dataObj =
           dataObj.value.QueryInterface(Components.interfaces.nsISupportsString);
       }
       catch (ex) {
         continue;
       }
 
       var transData = dataObj.data.split("\n");
-      var rows = transData[0].split(",");
+      var rows = transData[0].split(",").map(j => parseInt(j, 10));
       var numrows = rows.length;
 
       var result;
       // needToCopyCard is used for whether or not we should be creating
       // copies of the cards in a mailing list in a different address book
       // - it's not for if we are moving or not.
       var needToCopyCard = true;
       if (srcURI.length > targetURI.length) {
@@ -260,18 +260,21 @@
           needToCopyCard = false;
       }
 
       var directory = GetDirectoryFromURI(targetURI);
 
       // Only move if we are not transferring to a mail list
       var actionIsMoving = (dragSession.dragAction & dragSession.DRAGDROP_ACTION_MOVE) && !directory.isMailList;
 
+      let cardsToCopy = [];
       for (let j = 0; j < numrows; j++) {
-        let card = gAbView.getCardFromRow(rows[j]);
+        cardsToCopy.push(gAbView.getCardFromRow(rows[j]));
+      }
+      for (let card of cardsToCopy) {
         if (card.isMailList) {
           // This check ensures we haven't slipped through by mistake
           if (needToCopyCard && actionIsMoving) {
             directory.addMailList(GetDirectoryFromURI(card.mailListURI));
           }
         } else {
           let srcDirectory = null;
           if (srcURI == (kAllDirectoryRoot + "?") && actionIsMoving) {
