Bug 1719598 - fix unicode handling of file extensions in nsExternalHelperAppService, r=mtigley

Differential Revision: https://phabricator.services.mozilla.com/D120218
This commit is contained in:
Gijs Kruitbosch 2021-07-21 10:50:20 +00:00
Родитель 202b09af6c
Коммит a5bac38c6e
3 изменённых файлов: 19 добавлений и 1 удалений

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

@ -2800,7 +2800,7 @@ NS_IMETHODIMP nsExternalHelperAppService::GetFromTypeAndExtension(
// XXXzpao This should probably be localized
nsAutoCString desc(aFileExt);
desc.AppendLiteral(" File");
(*_retval)->SetDescription(NS_ConvertASCIItoUTF16(desc));
(*_retval)->SetDescription(NS_ConvertUTF8toUTF16(desc));
LOG(("Falling back to 'File' file description\n"));
}

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

@ -0,0 +1,17 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function test_utf8_extension() {
const mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
let someMIME = mimeService.getFromTypeAndExtension(
"application/x-gobbledygook",
".тест"
);
Assert.stringContains(someMIME.description, "тест");
// primary extension isn't set on macOS or android, see bug 1721181
if (AppConstants.platform != "macosx" && AppConstants.platform != "android") {
Assert.equal(someMIME.primaryExtension, ".тест");
}
});

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

@ -7,6 +7,7 @@ firefox-appdir = browser
# No default stored handlers on android given lack of support.
# No default stored handlers on Thunderbird.
skip-if = os == "android" || appname == "thunderbird"
[test_getFromTypeAndExtension.js]
[test_getMIMEInfo_pdf.js]
[test_getMIMEInfo_unknown_mime_type.js]
run-if = os == "win" # Windows only test