зеркало из https://github.com/mozilla/pjs.git
Add a code to unescape with a charset for a non ASCII file name,
bug 163682, r=jbetak, sr=bzbarsky, a=rjesup@wgate.com.
This commit is contained in:
Родитель
f37549746a
Коммит
b332fd32ba
|
@ -651,10 +651,25 @@ function getDefaultFileName(aDefaultFileName, aNameFromHeaders, aDocumentURI, aD
|
|||
// 2) Use the actual file name, if present
|
||||
return unescape(url.fileName);
|
||||
}
|
||||
} catch (e) {
|
||||
try {
|
||||
// the file name might be non ASCII
|
||||
// try unescape again with a characterSet
|
||||
var textToSubURI = Components.classes["@mozilla.org/intl/texttosuburi;1"]
|
||||
.getService(Components.interfaces.nsITextToSubURI);
|
||||
var charset;
|
||||
if (aDocument)
|
||||
charset = aDocument.characterSet;
|
||||
else if (document.commandDispatcher.focusedWindow)
|
||||
charset = document.commandDispatcher.focusedWindow.document.characterSet;
|
||||
else
|
||||
charset = window._content.document.characterSet;
|
||||
return textToSubURI.unEscapeURIForUI(charset, url.fileName);
|
||||
} catch (e) {
|
||||
// This is something like a wyciwyg:, data:, and so forth
|
||||
// URI... no usable filename here.
|
||||
}
|
||||
}
|
||||
|
||||
if (aDocument) {
|
||||
var docTitle = validateFileName(aDocument.title).replace(/^\s+|\s+$/g, "");
|
||||
|
|
Загрузка…
Ссылка в новой задаче