Bug 346994: part 1, remove leading dots from filenames before saving, r=mano

This commit is contained in:
gavin@gavinsharp.com 2007-04-17 11:51:33 -07:00
Родитель 28f0026e63
Коммит 87da89bad6
2 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -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(".");

Просмотреть файл

@ -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;
},