Bug 1680139 - Stop re-escaping IDN blocklisted characters in uriloader/exthandler/. r=mtigley

Differential Revision: https://phabricator.services.mozilla.com/D134656
This commit is contained in:
Masatoshi Kimura 2021-12-30 17:32:05 +00:00
Родитель f99d59644a
Коммит 04fd3c299a
3 изменённых файлов: 51 добавлений и 1 удалений

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

@ -153,7 +153,8 @@ static nsresult UnescapeFragment(const nsACString& aFragment, nsIURI* aURI,
do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
return textToSubURI->UnEscapeURIForUI(aFragment, aResult);
return textToSubURI->UnEscapeURIForUI(aFragment, /* aDontEscape = */ true,
aResult);
}
/**

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

@ -17,6 +17,8 @@ support-files =
run-if = os == 'linux'
support-files = download.bin
[browser_download_always_ask_preferred_app.js]
[browser_download_idn_blocklist.js]
support-files = download.bin
[browser_local_files_no_save_without_asking.js]
support-files =
file_pdf_binary_octet_stream.pdf

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

@ -0,0 +1,47 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const TEST_HOST = "example.org";
const TEST_FILE = "\u3002.bin";
const TEST_URL = `http://${TEST_HOST}/${TEST_FILE}`;
const { XPCShellContentUtils } = ChromeUtils.import(
"resource://testing-common/XPCShellContentUtils.jsm"
);
XPCShellContentUtils.initMochitest(this);
const server = XPCShellContentUtils.createHttpServer({
hosts: [TEST_HOST],
});
let file = getChromeDir(getResolvedURI(gTestPath));
file.append("download.bin");
server.registerFile(`/${encodeURIComponent(TEST_FILE)}`, file);
/**
* Check that IDN blocklisted characters are not escaped in
* download file names.
*/
add_task(async function test_idn_blocklisted_char_not_escaped() {
await SpecialPowers.pushPrefEnv({
set: [
// Enable downloads improvements
["browser.download.improvements_to_download_panel", true],
],
});
info("Testing with " + TEST_URL);
let publicList = await Downloads.getList(Downloads.PUBLIC);
let downloadFinished = promiseDownloadFinished(publicList);
var tab = BrowserTestUtils.addTab(gBrowser, TEST_URL);
let dl = await downloadFinished;
ok(dl.succeeded, "Download should succeed.");
Assert.equal(
PathUtils.filename(dl.target.path),
TEST_FILE,
"Should not escape a download file name."
);
await IOUtils.remove(dl.target.path);
BrowserTestUtils.removeTab(tab);
});