From a9da234f0d2d2904caa7fbc0ee82d4c7e2825929 Mon Sep 17 00:00:00 2001 From: "gavin%gavinsharp.com" Date: Wed, 18 Apr 2007 19:58:33 +0000 Subject: [PATCH] Bug 346994: part 1, remove leading dots from filenames before saving, r=mano, a=dveditz git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_0_BRANCH@224698 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/toolkit/content/contentAreaUtils.js | 3 +++ mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/mozilla/toolkit/content/contentAreaUtils.js b/mozilla/toolkit/content/contentAreaUtils.js index 20f4b6c2210..936f63d1955 100644 --- a/mozilla/toolkit/content/contentAreaUtils.js +++ b/mozilla/toolkit/content/contentAreaUtils.js @@ -897,6 +897,9 @@ function getNormalizedLeafName(aFile, aDefaultExtension) // Remove trailing dots and spaces on windows aFile = aFile.replace(/[\s.]+$/, ""); #endif + + // Remove leading dots + aFile = aFile.replace(/^\.+/, ""); // Fix up the file name we're saving to to include the default extension var i = aFile.lastIndexOf("."); diff --git a/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in b/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in index 7a8b8b8f59d..8d347fd894e 100644 --- a/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in +++ b/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in @@ -248,6 +248,10 @@ nsUnknownContentTypeDialog.prototype = { if (!aLocalFile || !aLocalFile.exists()) return null; + // Remove any leading periods, since we don't want to save hidden files + // automatically. + aLeafName = aLeafName.replace(/^\.+/, ""); + if (aLeafName == "") aLeafName = "unnamed" + (aFileExt ? "." + aFileExt : ""); aLocalFile.append(aLeafName);