mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1172080 - Part 2: Use ^ instead of ! to delimit originAttributes from the URI in nsIPrincipal.origin, r=bholley
This commit is contained in:
parent
6d21095ab0
commit
aec7e095c8
@ -51,7 +51,7 @@ OriginAttributes::CreateSuffix(nsACString& aStr) const
|
|||||||
|
|
||||||
params->Serialize(value);
|
params->Serialize(value);
|
||||||
if (!value.IsEmpty()) {
|
if (!value.IsEmpty()) {
|
||||||
aStr.AppendLiteral("!");
|
aStr.AppendLiteral("^");
|
||||||
aStr.Append(NS_ConvertUTF16toUTF8(value));
|
aStr.Append(NS_ConvertUTF16toUTF8(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ OriginAttributes::PopulateFromSuffix(const nsACString& aStr)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aStr[0] != '!') {
|
if (aStr[0] != '^') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ OriginAttributes::PopulateFromOrigin(const nsACString& aOrigin,
|
|||||||
{
|
{
|
||||||
// RFindChar is only available on nsCString.
|
// RFindChar is only available on nsCString.
|
||||||
nsCString origin(aOrigin);
|
nsCString origin(aOrigin);
|
||||||
int32_t pos = origin.RFindChar('!');
|
int32_t pos = origin.RFindChar('^');
|
||||||
|
|
||||||
if (pos == kNotFound) {
|
if (pos == kNotFound) {
|
||||||
aOriginNoSuffix = origin;
|
aOriginNoSuffix = origin;
|
||||||
|
@ -68,33 +68,33 @@ function run_test() {
|
|||||||
// Just app.
|
// Just app.
|
||||||
var exampleOrg_app = ssm.createCodebasePrincipal(makeURI('http://example.org'), {appId: 42});
|
var exampleOrg_app = ssm.createCodebasePrincipal(makeURI('http://example.org'), {appId: 42});
|
||||||
var nullPrin_app = ssm.createNullPrincipal({appId: 42});
|
var nullPrin_app = ssm.createNullPrincipal({appId: 42});
|
||||||
checkOriginAttributes(exampleOrg_app, {appId: 42}, '!appId=42');
|
checkOriginAttributes(exampleOrg_app, {appId: 42}, '^appId=42');
|
||||||
checkOriginAttributes(nullPrin_app, {appId: 42}, '!appId=42');
|
checkOriginAttributes(nullPrin_app, {appId: 42}, '^appId=42');
|
||||||
do_check_eq(exampleOrg_app.origin, 'http://example.org!appId=42');
|
do_check_eq(exampleOrg_app.origin, 'http://example.org^appId=42');
|
||||||
|
|
||||||
// Just browser.
|
// Just browser.
|
||||||
var exampleOrg_browser = ssm.createCodebasePrincipal(makeURI('http://example.org'), {inBrowser: true});
|
var exampleOrg_browser = ssm.createCodebasePrincipal(makeURI('http://example.org'), {inBrowser: true});
|
||||||
var nullPrin_browser = ssm.createNullPrincipal({inBrowser: true});
|
var nullPrin_browser = ssm.createNullPrincipal({inBrowser: true});
|
||||||
checkOriginAttributes(exampleOrg_browser, {inBrowser: true}, '!inBrowser=1');
|
checkOriginAttributes(exampleOrg_browser, {inBrowser: true}, '^inBrowser=1');
|
||||||
checkOriginAttributes(nullPrin_browser, {inBrowser: true}, '!inBrowser=1');
|
checkOriginAttributes(nullPrin_browser, {inBrowser: true}, '^inBrowser=1');
|
||||||
do_check_eq(exampleOrg_browser.origin, 'http://example.org!inBrowser=1');
|
do_check_eq(exampleOrg_browser.origin, 'http://example.org^inBrowser=1');
|
||||||
|
|
||||||
// App and browser.
|
// App and browser.
|
||||||
var exampleOrg_appBrowser = ssm.createCodebasePrincipal(makeURI('http://example.org'), {inBrowser: true, appId: 42});
|
var exampleOrg_appBrowser = ssm.createCodebasePrincipal(makeURI('http://example.org'), {inBrowser: true, appId: 42});
|
||||||
var nullPrin_appBrowser = ssm.createNullPrincipal({inBrowser: true, appId: 42});
|
var nullPrin_appBrowser = ssm.createNullPrincipal({inBrowser: true, appId: 42});
|
||||||
checkOriginAttributes(exampleOrg_appBrowser, {appId: 42, inBrowser: true}, '!appId=42&inBrowser=1');
|
checkOriginAttributes(exampleOrg_appBrowser, {appId: 42, inBrowser: true}, '^appId=42&inBrowser=1');
|
||||||
checkOriginAttributes(nullPrin_appBrowser, {appId: 42, inBrowser: true}, '!appId=42&inBrowser=1');
|
checkOriginAttributes(nullPrin_appBrowser, {appId: 42, inBrowser: true}, '^appId=42&inBrowser=1');
|
||||||
do_check_eq(exampleOrg_appBrowser.origin, 'http://example.org!appId=42&inBrowser=1');
|
do_check_eq(exampleOrg_appBrowser.origin, 'http://example.org^appId=42&inBrowser=1');
|
||||||
|
|
||||||
// App and browser, different domain.
|
// App and browser, different domain.
|
||||||
var exampleCom_appBrowser = ssm.createCodebasePrincipal(makeURI('https://www.example.com:123'), {appId: 42, inBrowser: true});
|
var exampleCom_appBrowser = ssm.createCodebasePrincipal(makeURI('https://www.example.com:123'), {appId: 42, inBrowser: true});
|
||||||
checkOriginAttributes(exampleCom_appBrowser, {appId: 42, inBrowser: true}, '!appId=42&inBrowser=1');
|
checkOriginAttributes(exampleCom_appBrowser, {appId: 42, inBrowser: true}, '^appId=42&inBrowser=1');
|
||||||
do_check_eq(exampleCom_appBrowser.origin, 'https://www.example.com:123!appId=42&inBrowser=1');
|
do_check_eq(exampleCom_appBrowser.origin, 'https://www.example.com:123^appId=42&inBrowser=1');
|
||||||
|
|
||||||
// Addon.
|
// Addon.
|
||||||
var exampleOrg_addon = ssm.createCodebasePrincipal(makeURI('http://example.org'), {addonId: 'dummy'});
|
var exampleOrg_addon = ssm.createCodebasePrincipal(makeURI('http://example.org'), {addonId: 'dummy'});
|
||||||
checkOriginAttributes(exampleOrg_addon, { addonId: "dummy" }, '!addonId=dummy');
|
checkOriginAttributes(exampleOrg_addon, { addonId: "dummy" }, '^addonId=dummy');
|
||||||
do_check_eq(exampleOrg_addon.origin, 'http://example.org!addonId=dummy');
|
do_check_eq(exampleOrg_addon.origin, 'http://example.org^addonId=dummy');
|
||||||
|
|
||||||
// Check that all of the above are cross-origin.
|
// Check that all of the above are cross-origin.
|
||||||
checkCrossOrigin(exampleOrg_app, exampleOrg);
|
checkCrossOrigin(exampleOrg_app, exampleOrg);
|
||||||
|
@ -51,7 +51,7 @@ add_test(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Assert.ok(mozapp.principal, "app principal should exist");
|
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,
|
Assert.equal(mozapp.principal.origin, expectedPrincipalOrigin,
|
||||||
"app principal origin ok");
|
"app principal origin ok");
|
||||||
Assert.equal(mozapp.principal.appId, app.localId, "app principal appId ok");
|
Assert.equal(mozapp.principal.appId, app.localId, "app principal appId ok");
|
||||||
|
@ -40,7 +40,7 @@ add_task(function* do_test() {
|
|||||||
conv.writeString("host\t" + TEST_PERMISSION + "\t1\t" + TEST_ORIGIN.host + "\n");
|
conv.writeString("host\t" + TEST_PERMISSION + "\t1\t" + TEST_ORIGIN.host + "\n");
|
||||||
conv.writeString("host\t" + TEST_PERMISSION + "\t1\t" + TEST_ORIGIN_2.host + "\n");
|
conv.writeString("host\t" + TEST_PERMISSION + "\t1\t" + TEST_ORIGIN_2.host + "\n");
|
||||||
conv.writeString("origin\t" + TEST_PERMISSION + "\t1\t" + TEST_ORIGIN_3.spec + "\n");
|
conv.writeString("origin\t" + TEST_PERMISSION + "\t1\t" + TEST_ORIGIN_3.spec + "\n");
|
||||||
conv.writeString("origin\t" + TEST_PERMISSION + "\t1\t" + TEST_ORIGIN.spec + "!appId=1000&inBrowser=1\n");
|
conv.writeString("origin\t" + TEST_PERMISSION + "\t1\t" + TEST_ORIGIN.spec + "^appId=1000&inBrowser=1\n");
|
||||||
ostream.close();
|
ostream.close();
|
||||||
|
|
||||||
// Set the preference used by the permission manager so the file is read.
|
// Set the preference used by the permission manager so the file is read.
|
||||||
|
@ -94,33 +94,33 @@ add_task(function test() {
|
|||||||
// However, permissions for subdomains of foo.com will be present for both http:// and https://,
|
// However, permissions for subdomains of foo.com will be present for both http:// and https://,
|
||||||
// as they do not apply to any entry in the history
|
// as they do not apply to any entry in the history
|
||||||
// ["http://foo.com", "A", 1, 0, 0],
|
// ["http://foo.com", "A", 1, 0, 0],
|
||||||
// ["http://foo.com!appId=1000", "A", 1, 0, 0],
|
// ["http://foo.com^appId=1000", "A", 1, 0, 0],
|
||||||
// ["http://foo.com!appId=2000&inBrowser=1", "A", 1, 0, 0],
|
// ["http://foo.com^appId=2000&inBrowser=1", "A", 1, 0, 0],
|
||||||
|
|
||||||
["http://sub.foo.com", "B", 1, 0, 0],
|
["http://sub.foo.com", "B", 1, 0, 0],
|
||||||
["http://subber.sub.foo.com", "B", 1, 0, 0],
|
["http://subber.sub.foo.com", "B", 1, 0, 0],
|
||||||
|
|
||||||
["https://foo.com", "A", 1, 0, 0],
|
["https://foo.com", "A", 1, 0, 0],
|
||||||
["https://foo.com!appId=1000", "A", 1, 0, 0],
|
["https://foo.com^appId=1000", "A", 1, 0, 0],
|
||||||
["https://foo.com!appId=2000&inBrowser=1", "A", 1, 0, 0],
|
["https://foo.com^appId=2000&inBrowser=1", "A", 1, 0, 0],
|
||||||
["https://sub.foo.com", "B", 1, 0, 0],
|
["https://sub.foo.com", "B", 1, 0, 0],
|
||||||
["https://subber.sub.foo.com", "B", 1, 0, 0],
|
["https://subber.sub.foo.com", "B", 1, 0, 0],
|
||||||
|
|
||||||
// bar.ca will have both http:// and https:// for all entries, because the foo did the bar a favour
|
// bar.ca will have both http:// and https:// for all entries, because the foo did the bar a favour
|
||||||
["http://bar.ca", "B", 1, 0, 0],
|
["http://bar.ca", "B", 1, 0, 0],
|
||||||
["https://bar.ca", "B", 1, 0, 0],
|
["https://bar.ca", "B", 1, 0, 0],
|
||||||
["http://bar.ca!appId=1000", "B", 1, 0, 0],
|
["http://bar.ca^appId=1000", "B", 1, 0, 0],
|
||||||
["https://bar.ca!appId=1000", "B", 1, 0, 0],
|
["https://bar.ca^appId=1000", "B", 1, 0, 0],
|
||||||
["http://bar.ca!appId=1000&inBrowser=1", "A", 1, 0, 0],
|
["http://bar.ca^appId=1000&inBrowser=1", "A", 1, 0, 0],
|
||||||
["https://bar.ca!appId=1000&inBrowser=1", "A", 1, 0, 0],
|
["https://bar.ca^appId=1000&inBrowser=1", "A", 1, 0, 0],
|
||||||
["file:///some/path/to/file.html", "A", 1, 0, 0],
|
["file:///some/path/to/file.html", "A", 1, 0, 0],
|
||||||
["file:///another/file.html", "A", 1, 0, 0],
|
["file:///another/file.html", "A", 1, 0, 0],
|
||||||
|
|
||||||
// Because we put ftp://some.subdomain.of.foo.com:8000/some/subdirectory in the history, we should
|
// Because we put ftp://some.subdomain.of.foo.com:8000/some/subdirectory in the history, we should
|
||||||
// also have these entries
|
// also have these entries
|
||||||
["ftp://foo.com:8000", "A", 1, 0, 0],
|
["ftp://foo.com:8000", "A", 1, 0, 0],
|
||||||
["ftp://foo.com:8000!appId=1000", "A", 1, 0, 0],
|
["ftp://foo.com:8000^appId=1000", "A", 1, 0, 0],
|
||||||
["ftp://foo.com:8000!appId=2000&inBrowser=1", "A", 1, 0, 0],
|
["ftp://foo.com:8000^appId=2000&inBrowser=1", "A", 1, 0, 0],
|
||||||
];
|
];
|
||||||
|
|
||||||
let found = expected.map((it) => 0);
|
let found = expected.map((it) => 0);
|
||||||
|
@ -105,7 +105,7 @@ this.BrowserUtils = {
|
|||||||
throw new Error("principalFromOrigin does not support nsNullPrincipal");
|
throw new Error("principalFromOrigin does not support nsNullPrincipal");
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = aOriginString.split('!');
|
var parts = aOriginString.split('^');
|
||||||
if (parts.length > 2) {
|
if (parts.length > 2) {
|
||||||
throw new Error("bad origin string: " + aOriginString);
|
throw new Error("bad origin string: " + aOriginString);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user