diff --git a/mozilla/toolkit/content/contentAreaUtils.js b/mozilla/toolkit/content/contentAreaUtils.js index c880d26b9db..cff7abcf91b 100644 --- a/mozilla/toolkit/content/contentAreaUtils.js +++ b/mozilla/toolkit/content/contentAreaUtils.js @@ -830,6 +830,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 3a6d2c61ce4..4fd8ba9cf8a 100644 --- a/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in +++ b/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in @@ -273,6 +273,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); @@ -286,6 +290,7 @@ nsUnknownContentTypeDialog.prototype = { f.remove(false); this.makeFileUnique(aLocalFile); } + return aLocalFile; },