Bug 1329494 - remove ? from chrome URI to encode e-mail addresses in permissions manager. r=mkmelin a=Ratty(SM)

--HG--
extra : amend_source : 6446210b5b2625594398b446406c7550100cd1bf
This commit is contained in:
Jorg K 2017-01-11 23:54:35 +01:00
Родитель 9177e11003
Коммит 956373e808
7 изменённых файлов: 13 добавлений и 13 удалений

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

@ -3200,7 +3200,7 @@ function onRemoteContentOptionsShowing(aEvent) {
if (adrCount > 0) {
let authorEmailAddress = addresses.value[0];
let authorEmailAddressURI = Services.io.newURI(
"chrome://messenger/content/?email=" + authorEmailAddress);
"chrome://messenger/content/email=" + authorEmailAddress);
let mailPrincipal = Services.scriptSecurityManager
.createCodebasePrincipal(authorEmailAddressURI, {});
origins.push(mailPrincipal.origin);
@ -3223,11 +3223,11 @@ function onRemoteContentOptionsShowing(aEvent) {
let menuitem = document.createElement("menuitem");
menuitem.setAttribute("label",
messengerBundle.getFormattedString("remoteAllowResource",
[origin.replace("chrome://messenger/content/?email=", "")]));
[origin.replace("chrome://messenger/content/email=", "")]));
menuitem.setAttribute("value", origin);
menuitem.setAttribute("class", "allow-remote-uri");
menuitem.setAttribute("oncommand", "allowRemoteContentForURI(this.value);");
if (origin.startsWith("chrome://messenger/content/?email="))
if (origin.startsWith("chrome://messenger/content/email="))
aEvent.target.appendChild(menuitem);
else
aEvent.target.insertBefore(menuitem, urlSepar);
@ -3264,7 +3264,7 @@ function allowRemoteContentForURI(aUriSpec, aReload = true) {
function allowRemoteContentForAll(aListNode) {
let uriNodes = aListNode.querySelectorAll(".allow-remote-uri");
for (let uriNode of uriNodes) {
if (!uriNode.value.startsWith("chrome://messenger/content/?email="))
if (!uriNode.value.startsWith("chrome://messenger/content/email="))
allowRemoteContentForURI(uriNode.value, false);
}
ReloadMessage();

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

@ -14,7 +14,7 @@ var NOTIFICATION_FLUSH_PERMISSIONS = "flush-pending-permissions";
* Magic URI base used so the permission manager can store
* remote content permissions for a given email address.
*/
var MAILURI_BASE = "chrome://messenger/content/?email=";
var MAILURI_BASE = "chrome://messenger/content/email=";
function Permission(principal, type, capability)
{

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

@ -309,7 +309,7 @@ function checkAllowForSenderWithPerms(test) {
MailServices.headerParser.parseHeadersWithArray(msgDbHdr.author, addresses, {}, {});
let authorEmailAddress = addresses.value[0];
let uri = Services.io.newURI("chrome://messenger/content/?email=" + authorEmailAddress);
let uri = Services.io.newURI("chrome://messenger/content/email=" + authorEmailAddress);
Services.perms.add(uri, "image", Services.perms.ALLOW_ACTION);
assert_true(Services.perms.testPermission(uri, "image") ==
Services.perms.ALLOW_ACTION);

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

@ -111,7 +111,7 @@ nsMsgContentPolicy::ShouldAcceptRemoteContentForSender(nsIMsgDBHdr *aMsgHdr)
nsCOMPtr<nsIIOService> ios = do_GetService("@mozilla.org/network/io-service;1", &rv);
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIURI> mailURI;
emailAddress.Insert("chrome://messenger/content/?email=", 0);
emailAddress.Insert("chrome://messenger/content/email=", 0);
rv = ios->NewURI(emailAddress, nullptr, nullptr, getter_AddRefs(mailURI));
NS_ENSURE_SUCCESS(rv, false);

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

@ -33,11 +33,11 @@ function run_test() {
testAB.copyTo(do_get_profile(), kPABData.fileName);
let uriAllowed = Services.io.newURI(
"chrome://messenger/content/?email=yes@test.invalid");
"chrome://messenger/content/email=yes@test.invalid");
let uriAllowed2 = Services.io.newURI(
"chrome://messenger/content/?email=yes2@test.invalid");
"chrome://messenger/content/email=yes2@test.invalid");
let uriDisallowed = Services.io.newURI(
"chrome://messenger/content/?email=no@test.invalid");
"chrome://messenger/content/email=no@test.invalid");
// Check that this email that according to the ab data has (had!)
// remote content premissions, has no premissions pre migration.

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

@ -132,7 +132,7 @@ function MigrateABRemoteContentSettings()
{
let migrateAddress = function(aEmail) {
let uri = Services.io.newURI(
"chrome://messenger/content/?email=" + aEmail);
"chrome://messenger/content/email=" + aEmail);
Services.perms.add(uri, "image", Services.perms.ALLOW_ACTION);
}

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

@ -2762,7 +2762,7 @@ function onRemoteContentOptionsShowing(aEvent)
var authorEmailAddress = addresses.value[0];
var emailURI = Services.io.newURI(
"chrome://messenger/content/?email=" + authorEmailAddress);
"chrome://messenger/content/email=" + authorEmailAddress);
var principal = Services.scriptSecurityManager
.createCodebasePrincipal(emailURI, {});
// Put author email first in the menu.
@ -2780,7 +2780,7 @@ function onRemoteContentOptionsShowing(aEvent)
for (let origin of origins)
{
let menuitem = document.createElement("menuitem");
let host = origin.replace("chrome://messenger/content/?email=", "");
let host = origin.replace("chrome://messenger/content/email=", "");
let hostString = messengerBundle.getFormattedString("remoteContentAllow", [host]);
menuitem.setAttribute("label", hostString);
menuitem.setAttribute("value", origin);