From d6917672bfc2fbd446c87dfd00452a3187fa7e1b Mon Sep 17 00:00:00 2001 From: "gavin%gavinsharp.com" Date: Sat, 17 Sep 2005 02:27:45 +0000 Subject: [PATCH] Bug 290381: "Save Link As..." doubles the extension if the link contains an escaped hash/pound (#) sign encoded as %23, patch by Caleb , r=mconnor --- toolkit/content/contentAreaUtils.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/toolkit/content/contentAreaUtils.js b/toolkit/content/contentAreaUtils.js index 328bed644a62..d2c2bc3f601d 100644 --- a/toolkit/content/contentAreaUtils.js +++ b/toolkit/content/contentAreaUtils.js @@ -884,14 +884,15 @@ function getNormalizedLeafName(aFile, aDefaultExtension) { if (!aDefaultExtension) return aFile; - + +#ifdef XP_WIN + // Remove trailing dots and spaces on windows + aFile = aFile.replace(/[\s.]+$/, ""); +#endif + // Fix up the file name we're saving to to include the default extension - const stdURLContractID = "@mozilla.org/network/standard-url;1"; - const stdURLIID = Components.interfaces.nsIURL; - var url = Components.classes[stdURLContractID].createInstance(stdURLIID); - url.filePath = aFile; - - if (url.fileExtension != aDefaultExtension) + var i = aFile.lastIndexOf("."); + if (aFile.substr(i + 1) != aDefaultExtension) return aFile + "." + aDefaultExtension; return aFile;