Save as on a page with no filename and title should not just die. Bug

158598, patch by sharparrow1@yahoo.com, r=timeless, sr=bzbarsky.
This commit is contained in:
bzbarsky%mit.edu 2006-07-29 05:41:17 +00:00
Родитель abb3841962
Коммит d18daed50a
2 изменённых файлов: 25 добавлений и 6 удалений

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

@ -642,24 +642,42 @@ function getMIMEInfoForType(aMIMEType)
function getDefaultFileName(aDefaultFileName, aNameFromHeaders, aDocumentURI, aDocument)
{
if (aNameFromHeaders)
return validateFileName(aNameFromHeaders); // 1) Use the name suggested by the HTTP headers
// 1) Use the name suggested by the HTTP headers
return validateFileName(aNameFromHeaders);
try {
var url = aDocumentURI.QueryInterface(Components.interfaces.nsIURL);
if (url.fileName != "")
return url.fileName; // 2) Use the actual file name, if present
// 2) Use the actual file name, if present
return url.fileName;
} catch (e) {
// This is something like a wyciwyg:, data:, and so forth
// URI... no usable filename here.
}
if (aDocument && aDocument.title != "")
return validateFileName(aDocument.title) // 3) Use the document title
if (aDocument && aDocument.title != "")
// 3) Use the document title
return validateFileName(aDocument.title);
if (aDefaultFileName)
return validateFileName(aDefaultFileName); // 4) Use the caller-provided name, if any
// 4) Use the caller-provided name, if any
return validateFileName(aDefaultFileName);
return aDocumentURI.host; // 5) Use the host.
try {
if (aDocumentURI.host)
// 5) Use the host.
return aDocumentURI.host;
} catch (e) {
// Some files have no information at all, like Javascript generated pages
}
try {
// 6) Use the default file name
return getStringBundle().GetStringFromName("DefaultSaveFileName");
} catch (e) {
//in case localized string cannot be found
}
// 7) If all else fails, use "index"
return "index";
}
function validateFileName(aFileName)

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

@ -5,6 +5,7 @@ searchText=Web Search for "%S"
SavePageTitle=Save Web Page
SaveImageTitle=Save Picture
SaveLinkTitle=Save As
DefaultSaveFileName=index
WebPageCompleteFilter=Web Page, complete
WebPageHTMLOnlyFilter=Web Page, HTML only
TextOnlyFilter=Text File