From 23896f6de1a2a97f5895909c0b4380878ddfd60e Mon Sep 17 00:00:00 2001 From: roytam1 Date: Tue, 28 Dec 2021 09:25:23 +0800 Subject: [PATCH] partly import changes from `dev' branch of rmottola/Arctic-Fox: - Bug 1172080 - Part 2: Use ^ instead of ! to delimit originAttributes from the URI in nsIPrincipal.origin, r=bholley (929ef38df) --- caps/BasePrincipal.cpp | 6 +++--- dom/apps/tests/unit/test_moziapplication.js | 2 +- toolkit/modules/BrowserUtils.jsm | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/caps/BasePrincipal.cpp b/caps/BasePrincipal.cpp index ed053ab8bc..cc77bcb9b5 100644 --- a/caps/BasePrincipal.cpp +++ b/caps/BasePrincipal.cpp @@ -51,7 +51,7 @@ OriginAttributes::CreateSuffix(nsACString& aStr) const params->Serialize(value); if (!value.IsEmpty()) { - aStr.AppendLiteral("!"); + aStr.AppendLiteral("^"); aStr.Append(NS_ConvertUTF16toUTF8(value)); } } @@ -117,7 +117,7 @@ OriginAttributes::PopulateFromSuffix(const nsACString& aStr) return true; } - if (aStr[0] != '!') { + if (aStr[0] != '^') { return false; } @@ -134,7 +134,7 @@ OriginAttributes::PopulateFromOrigin(const nsACString& aOrigin, { // RFindChar is only available on nsCString. nsCString origin(aOrigin); - int32_t pos = origin.RFindChar('!'); + int32_t pos = origin.RFindChar('^'); if (pos == kNotFound) { aOriginNoSuffix = origin; diff --git a/dom/apps/tests/unit/test_moziapplication.js b/dom/apps/tests/unit/test_moziapplication.js index 5488df18e2..8a6daa1452 100644 --- a/dom/apps/tests/unit/test_moziapplication.js +++ b/dom/apps/tests/unit/test_moziapplication.js @@ -51,7 +51,7 @@ add_test(() => { }); Assert.ok(mozapp.principal, "app principal should exist"); - let expectedPrincipalOrigin = app.origin + "!appId=" + app.localId; + let expectedPrincipalOrigin = app.origin + "^appId=" + app.localId; Assert.equal(mozapp.principal.origin, expectedPrincipalOrigin, "app principal origin ok"); Assert.equal(mozapp.principal.appId, app.localId, "app principal appId ok"); diff --git a/toolkit/modules/BrowserUtils.jsm b/toolkit/modules/BrowserUtils.jsm index eb20647a2b..d23200151b 100644 --- a/toolkit/modules/BrowserUtils.jsm +++ b/toolkit/modules/BrowserUtils.jsm @@ -115,7 +115,7 @@ this.BrowserUtils = { throw new Error("principalFromOrigin does not support nsNullPrincipal"); } - var parts = aOriginString.split('!'); + var parts = aOriginString.split('^'); if (parts.length > 2) { throw new Error("bad origin string: " + aOriginString); }