Skip to content

Commit 7dfa2e6

Browse files
committed
Added two library files (one, lib/restricted.js, missing from rc8 tag) and version bump.
1 parent 103324e commit 7dfa2e6

3 files changed

Lines changed: 61 additions & 1 deletion

File tree

src/lib/ContentMetaData.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
class ContentMetaData {
2+
constructor(request, defaultCharset = "utf-8") {
3+
this.defaultCharset = defaultCharset;
4+
let {responseHeaders} = request;
5+
for (let h of responseHeaders) {
6+
if (/^\s*Content-(Type|Disposition)\s*$/i.test(h.name)) {
7+
this[h.name.split("-")[1].trim().toLowerCase()] = h.value;
8+
}
9+
}
10+
}
11+
12+
get charset() {
13+
let charset = this.defaultCharset;
14+
if (this.type) {
15+
let m = this.type.match(/;\s*charset\s*=\s*(\S+)/);
16+
if (m) {
17+
charset = m[1];
18+
}
19+
}
20+
Object.defineProperty(this, "charset", { value: charset, writable: false, configurable: true })
21+
}
22+
23+
createDecoder() {
24+
try {
25+
return new TextDecoder(charset);
26+
} catch (e) {
27+
return new TextDecoder(this.defaultCharset);
28+
}
29+
}
30+
};

src/lib/restricted.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
// see https://bugzilla.mozilla.org/show_bug.cgi?id=1415644
3+
let domains = [
4+
"accounts-static.cdn.mozilla.net",
5+
"accounts.firefox.com",
6+
"addons.cdn.mozilla.net",
7+
"addons.mozilla.org",
8+
"api.accounts.firefox.com",
9+
"content.cdn.mozilla.net",
10+
"content.cdn.mozilla.net",
11+
"discovery.addons.mozilla.org",
12+
"input.mozilla.org",
13+
"install.mozilla.org",
14+
"oauth.accounts.firefox.com",
15+
"profile.accounts.firefox.com",
16+
"support.mozilla.org",
17+
"sync.services.mozilla.com",
18+
"testpilot.firefox.com",
19+
];
20+
21+
function isRestrictedURL(u) {
22+
try {
23+
if (typeof u === "string") u = new URL(u);
24+
return u.protocol === "https:" && domains.includes(u.hostname);
25+
} catch (e) {
26+
return false;
27+
}
28+
}
29+
}

src/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"strict_min_version": "59.0"
99
}
1010
},
11-
"version": "10.1.8.3rc8",
11+
"version": "10.1.8.3rc9",
1212
"description": "__MSG_Description__",
1313

1414
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'none'",
@@ -39,6 +39,7 @@
3939
"lib/include.js",
4040
"lib/punycode.js",
4141
"lib/tld.js",
42+
"lib/ContentMetaData.js",
4243
"common/Policy.js",
4344
"common/locale.js",
4445
"common/Entities.js",

0 commit comments

Comments
 (0)