From a6bff9568561c3e4b1f780ca68ad9839827da83a Mon Sep 17 00:00:00 2001 From: "reed%reedloden.com" Date: Sun, 6 Jan 2008 03:52:36 +0000 Subject: [PATCH] Bug 336286 - "Dragging Local files to Bookmarks Toolbar no longer works" [p=mak77@supereva.it (Marco Bonardo [mak77]) / torisugari@gmail.com (O. Atsushi [Torisugari]) r=Mano a=blocking-firefox3+] --- browser/components/places/content/utils.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/browser/components/places/content/utils.js b/browser/components/places/content/utils.js index 61e3baccbe6..42d38b3264c 100644 --- a/browser/components/places/content/utils.js +++ b/browser/components/places/content/utils.js @@ -767,11 +767,22 @@ var PlacesUtils = { var parts = blob.split("\n"); // data in this type has 2 parts per entry, so if there are fewer // than 2 parts left, the blob is malformed and we should stop - if (parts.length % 2) + // but drag and drop of files from the shell has parts.length = 1 + if (parts.length != 1 && parts.length % 2) break; for (var i = 0; i < parts.length; i=i+2) { var uriString = parts[i]; - var titleString = parts[i+1]; + var titleString = ""; + if (parts.length > i+1) + titleString = parts[i+1]; + else { + // for drag and drop of files, try to use the leafName as title + try { + titleString = IO.newURI(uriString).QueryInterface(Ci.nsIURL) + .fileName; + } + catch (e) {} + } // note: IO.newURI() will throw if uriString is not a valid URI if (IO.newURI(uriString)) { nodes.push({ uri: uriString,