Bug 1803405 - Port bug 1793463: Make NS_URIChainHasFlags (mostly) threadsafe. rs=bustage-fix
Differential Revision: https://phabricator.services.mozilla.com/D163578 --HG-- extra : rebase_source : 14bfdd08b948d08d661771763c4a19f8c5ac6b61
This commit is contained in:
Родитель
f5fa465ba7
Коммит
2bf0ec9488
|
@ -5,42 +5,30 @@
|
|||
var EXPORTED_SYMBOLS = ["CalProtocolHandlerWebcal", "CalProtocolHandlerWebcals"];
|
||||
|
||||
/**
|
||||
* Generic webcal constructor
|
||||
* CalProtocolHandler.
|
||||
*
|
||||
* @param scheme The scheme to init for (webcal, webcals)
|
||||
* @param {string} scheme - The scheme to init for (webcal, webcals).
|
||||
* @implements {nsIProtocolHandler}
|
||||
*/
|
||||
function calProtocolHandler(scheme) {
|
||||
this.scheme = scheme;
|
||||
this.mHttpProtocol = Services.io.getProtocolHandler(this.scheme == "webcal" ? "http" : "https");
|
||||
this.wrappedJSObject = this;
|
||||
}
|
||||
class CalProtocolHandlerWebcal {
|
||||
QueryInterface = ChromeUtils.generateQI(["nsIProtocolHandler"]);
|
||||
|
||||
calProtocolHandler.prototype = {
|
||||
get defaultPort() {
|
||||
return this.mHttpProtocol.defaultPort;
|
||||
},
|
||||
get protocolFlags() {
|
||||
return this.mHttpProtocol.protocolFlags;
|
||||
},
|
||||
scheme = "webcal";
|
||||
httpScheme = "http";
|
||||
httpPort = 80;
|
||||
|
||||
newURI(aSpec, anOriginalCharset, aBaseURI) {
|
||||
return Cc["@mozilla.org/network/standard-url-mutator;1"]
|
||||
.createInstance(Ci.nsIStandardURLMutator)
|
||||
.init(
|
||||
Ci.nsIStandardURL.URLTYPE_STANDARD,
|
||||
this.mHttpProtocol.defaultPort,
|
||||
aSpec,
|
||||
anOriginalCharset,
|
||||
aBaseURI
|
||||
)
|
||||
.init(Ci.nsIStandardURL.URLTYPE_STANDARD, this.httpPort, aSpec, anOriginalCharset, aBaseURI)
|
||||
.finalize()
|
||||
.QueryInterface(Ci.nsIStandardURL);
|
||||
},
|
||||
}
|
||||
|
||||
newChannel(aUri, aLoadInfo) {
|
||||
let uri = aUri
|
||||
.mutate()
|
||||
.setScheme(this.mHttpProtocol.scheme)
|
||||
.setScheme(this.httpScheme)
|
||||
.finalize();
|
||||
|
||||
let channel;
|
||||
|
@ -58,32 +46,21 @@ calProtocolHandler.prototype = {
|
|||
}
|
||||
channel.originalURI = aUri;
|
||||
return channel;
|
||||
},
|
||||
}
|
||||
|
||||
// We are not overriding any special ports
|
||||
allowPort(aPort, aScheme) {
|
||||
return false;
|
||||
},
|
||||
};
|
||||
|
||||
/** Constructor for webcal: protocol handler */
|
||||
function CalProtocolHandlerWebcal() {
|
||||
calProtocolHandler.call(this, "webcal");
|
||||
return false; // We are not overriding any special ports.
|
||||
}
|
||||
CalProtocolHandlerWebcal.prototype = {
|
||||
__proto__: calProtocolHandler.prototype,
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIProtocolHandler"]),
|
||||
classID: Components.ID("{1153c73a-39be-46aa-9ba9-656d188865ca}"),
|
||||
};
|
||||
|
||||
/** Constructor for webcals: protocol handler */
|
||||
function CalProtocolHandlerWebcals() {
|
||||
calProtocolHandler.call(this, "webcals");
|
||||
}
|
||||
CalProtocolHandlerWebcals.prototype = {
|
||||
__proto__: calProtocolHandler.prototype,
|
||||
CalProtocolHandlerWebcal.prototype.classID = Components.ID(
|
||||
"{1153c73a-39be-46aa-9ba9-656d188865ca}"
|
||||
);
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIProtocolHandler"]),
|
||||
classID: Components.ID("{bdf71224-365d-4493-856a-a7e74026f766}"),
|
||||
};
|
||||
class CalProtocolHandlerWebcals extends CalProtocolHandlerWebcal {
|
||||
scheme = "webcals";
|
||||
httpScheme = "http";
|
||||
httpPort = 443;
|
||||
}
|
||||
CalProtocolHandlerWebcals.prototype.classID = Components.ID(
|
||||
"{bdf71224-365d-4493-856a-a7e74026f766}"
|
||||
);
|
||||
|
|
|
@ -126,12 +126,34 @@ Classes = [
|
|||
"contract_ids": ["@mozilla.org/network/protocol;1?name=webcal"],
|
||||
"jsm": "resource:///modules/CalProtocolHandler.jsm",
|
||||
"constructor": "CalProtocolHandlerWebcal",
|
||||
"protocol_config": {
|
||||
"scheme": "webcal",
|
||||
"flags": [
|
||||
"URI_STD",
|
||||
"ALLOWS_PROXY",
|
||||
"ALLOWS_PROXY_HTTP",
|
||||
"URI_LOADABLE_BY_ANYONE",
|
||||
"URI_IS_POTENTIALLY_TRUSTWORTHY",
|
||||
],
|
||||
"default_port": 80,
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{bdf71224-365d-4493-856a-a7e74026f766}",
|
||||
"contract_ids": ["@mozilla.org/network/protocol;1?name=webcals"],
|
||||
"jsm": "resource:///modules/CalProtocolHandler.jsm",
|
||||
"constructor": "CalProtocolHandlerWebcals",
|
||||
"protocol_config": {
|
||||
"scheme": "webcals",
|
||||
"flags": [
|
||||
"URI_STD",
|
||||
"ALLOWS_PROXY",
|
||||
"ALLOWS_PROXY_HTTP",
|
||||
"URI_LOADABLE_BY_ANYONE",
|
||||
"URI_IS_POTENTIALLY_TRUSTWORTHY",
|
||||
],
|
||||
"default_port": 443,
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{806b6423-3aaa-4b26-afa3-de60563e9cec}",
|
||||
|
|
|
@ -13,14 +13,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
|
|||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
});
|
||||
|
||||
var ITIP_HANDLER_MIMETYPE = "application/x-itip-internal";
|
||||
var ITIP_HANDLER_PROTOCOL = "moz-cal-handle-itip";
|
||||
var NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
|
||||
|
||||
function NYI() {
|
||||
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
function ItipChannel(URI, aLoadInfo) {
|
||||
this.wrappedJSObject = this;
|
||||
this.URI = this.originalURI = URI;
|
||||
|
@ -30,7 +22,7 @@ ItipChannel.prototype = {
|
|||
QueryInterface: ChromeUtils.generateQI(["nsIChannel", "nsIRequest"]),
|
||||
classID: Components.ID("{643e0328-36f6-411d-a107-16238dff9cd7}"),
|
||||
|
||||
contentType: ITIP_HANDLER_MIMETYPE,
|
||||
contentType: "application/x-itip-internal",
|
||||
loadAttributes: null,
|
||||
contentLength: 0,
|
||||
owner: null,
|
||||
|
@ -38,14 +30,18 @@ ItipChannel.prototype = {
|
|||
notificationCallbacks: null,
|
||||
securityInfo: null,
|
||||
|
||||
open: NYI,
|
||||
open() {
|
||||
throw Components.Exception(
|
||||
`${this.constructor.name}.open not implemented`,
|
||||
Cr.NS_ERROR_NOT_IMPLEMENTED
|
||||
);
|
||||
},
|
||||
asyncOpen(observer) {
|
||||
observer.onStartRequest(this, null);
|
||||
},
|
||||
asyncRead(listener, ctxt) {
|
||||
return listener.onStartRequest(this, ctxt);
|
||||
},
|
||||
|
||||
isPending() {
|
||||
return true;
|
||||
},
|
||||
|
@ -53,10 +49,23 @@ ItipChannel.prototype = {
|
|||
cancel(status) {
|
||||
this.status = status;
|
||||
},
|
||||
suspend: NYI,
|
||||
resume: NYI,
|
||||
suspend() {
|
||||
throw Components.Exception(
|
||||
`${this.constructor.name}.suspend not implemented`,
|
||||
Cr.NS_ERROR_NOT_IMPLEMENTED
|
||||
);
|
||||
},
|
||||
resume() {
|
||||
throw Components.Exception(
|
||||
`${this.constructor.name}.resume not implemented`,
|
||||
Cr.NS_ERROR_NOT_IMPLEMENTED
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @implements {nsIProtocolHandler}
|
||||
*/
|
||||
function ItipProtocolHandler() {
|
||||
this.wrappedJSObject = this;
|
||||
}
|
||||
|
@ -64,7 +73,6 @@ ItipProtocolHandler.prototype = {
|
|||
QueryInterface: ChromeUtils.generateQI(["nsIProtocolHandler"]),
|
||||
classID: Components.ID("{6e957006-b4ce-11d9-b053-001124736B74}"),
|
||||
|
||||
protocolFlags: Ci.nsIProtocolHandler.URI_NORELATIVE | Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD,
|
||||
allowPort: () => false,
|
||||
isSecure: false,
|
||||
newChannel(URI, aLoadInfo) {
|
||||
|
@ -83,12 +91,10 @@ ItipContentHandler.prototype = {
|
|||
handleContent(contentType, windowTarget, request) {
|
||||
let channel = request.QueryInterface(Ci.nsIChannel);
|
||||
let uri = channel.URI.spec;
|
||||
if (!uri.startsWith(ITIP_HANDLER_PROTOCOL + ":")) {
|
||||
cal.ERROR("Unexpected iTIP uri: " + uri + "\n");
|
||||
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||
if (!uri.startsWith("moz-cal-handle-itip:")) {
|
||||
throw Components.Exception(`Unexpected iTIP uri: ${uri}`, Cr.NS_ERROR_WONT_HANDLE_CONTENT);
|
||||
}
|
||||
// moz-cal-handle-itip:///?
|
||||
let paramString = uri.substring(ITIP_HANDLER_PROTOCOL.length + 4);
|
||||
let paramString = uri.substring("moz-cal-handle-itip:///".length);
|
||||
let paramArray = paramString.split("&");
|
||||
let paramBlock = {};
|
||||
paramArray.forEach(value => {
|
||||
|
|
|
@ -22,6 +22,13 @@ Classes = [
|
|||
'contract_ids': ['@mozilla.org/network/protocol;1?name=moz-cal-handle-itip'],
|
||||
'jsm': 'resource:///modules/CalItipProtocolHandler.jsm',
|
||||
'constructor': 'ItipProtocolHandler',
|
||||
'protocol_config': {
|
||||
'scheme': 'moz-cal-handle-itip',
|
||||
'flags': [
|
||||
'URI_NORELATIVE',
|
||||
'URI_DANGEROUS_TO_LOAD',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
'cid': '{47c31f2b-b4de-11d9-bfe6-001124736B74}',
|
||||
|
|
|
@ -4,23 +4,16 @@
|
|||
|
||||
var EXPORTED_SYMBOLS = ["LDAPProtocolHandler", "LDAPSProtocolHandler"];
|
||||
|
||||
const nsIProtocolHandler = Ci.nsIProtocolHandler;
|
||||
/**
|
||||
* @implements {nsIProtocolHandler}
|
||||
*/
|
||||
class LDAPProtocolHandler {
|
||||
QueryInterface = ChromeUtils.generateQI(["nsIProtocolHandler"]);
|
||||
|
||||
function makeProtocolHandler(aCID, aProtocol, aDefaultPort) {
|
||||
return {
|
||||
classID: Components.ID(aCID),
|
||||
QueryInterface: ChromeUtils.generateQI([nsIProtocolHandler]),
|
||||
|
||||
scheme: aProtocol,
|
||||
defaultPort: aDefaultPort,
|
||||
protocolFlags:
|
||||
nsIProtocolHandler.URI_NORELATIVE |
|
||||
nsIProtocolHandler.URI_DANGEROUS_TO_LOAD |
|
||||
nsIProtocolHandler.ALLOWS_PROXY,
|
||||
scheme = "ldap";
|
||||
|
||||
newChannel(aURI, aLoadInfo) {
|
||||
if ("@mozilla.org/network/ldap-channel;1" in Cc) {
|
||||
var channel = Cc["@mozilla.org/network/ldap-channel;1"].createInstance(
|
||||
let channel = Cc["@mozilla.org/network/ldap-channel;1"].createInstance(
|
||||
Ci.nsIChannel
|
||||
);
|
||||
channel.init(aURI);
|
||||
|
@ -28,27 +21,21 @@ function makeProtocolHandler(aCID, aProtocol, aDefaultPort) {
|
|||
return channel;
|
||||
}
|
||||
|
||||
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
|
||||
},
|
||||
allowPort(port, scheme) {
|
||||
return port == 389;
|
||||
}
|
||||
}
|
||||
LDAPProtocolHandler.prototype.classID = Components.ID(
|
||||
"{b3de9249-b0e5-4c12-8d91-c9a434fd80f5}"
|
||||
);
|
||||
|
||||
class LDAPSProtocolHandler extends LDAPProtocolHandler {
|
||||
scheme = "ldaps";
|
||||
|
||||
allowPort(port, scheme) {
|
||||
return port == aDefaultPort;
|
||||
},
|
||||
};
|
||||
return port == 636;
|
||||
}
|
||||
|
||||
function LDAPProtocolHandler() {}
|
||||
|
||||
LDAPProtocolHandler.prototype = makeProtocolHandler(
|
||||
"{b3de9249-b0e5-4c12-8d91-c9a434fd80f5}",
|
||||
"ldap",
|
||||
389
|
||||
);
|
||||
|
||||
function LDAPSProtocolHandler() {}
|
||||
|
||||
LDAPSProtocolHandler.prototype = makeProtocolHandler(
|
||||
"{c85a5ef2-9c56-445f-b029-76889f2dd29b}",
|
||||
"ldaps",
|
||||
636
|
||||
}
|
||||
LDAPSProtocolHandler.prototype.classID = Components.ID(
|
||||
"{c85a5ef2-9c56-445f-b029-76889f2dd29b}"
|
||||
);
|
||||
|
|
|
@ -98,12 +98,30 @@ Classes = [
|
|||
"contract_ids": ["@mozilla.org/network/protocol;1?name=ldap"],
|
||||
"jsm": "resource:///modules/LDAPProtocolHandler.jsm",
|
||||
"constructor": "LDAPProtocolHandler",
|
||||
"protocol_config": {
|
||||
"scheme": "ldap",
|
||||
"flags": [
|
||||
"URI_NORELATIVE",
|
||||
"URI_DANGEROUS_TO_LOAD",
|
||||
"ALLOWS_PROXY",
|
||||
],
|
||||
"default_port": 389,
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{c85a5ef2-9c56-445f-b029-76889f2dd29b}",
|
||||
"contract_ids": ["@mozilla.org/network/protocol;1?name=ldaps"],
|
||||
"jsm": "resource:///modules/LDAPProtocolHandler.jsm",
|
||||
"constructor": "LDAPSProtocolHandler",
|
||||
"protocol_config": {
|
||||
"scheme": "ldaps",
|
||||
"flags": [
|
||||
"URI_NORELATIVE",
|
||||
"URI_DANGEROUS_TO_LOAD",
|
||||
"ALLOWS_PROXY",
|
||||
],
|
||||
"default_port": 636,
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
|
|
|
@ -242,6 +242,12 @@ Classes = [
|
|||
"contract_ids": ["@mozilla.org/network/protocol;1?name=cid"],
|
||||
"type": "nsCidProtocolHandler",
|
||||
"headers": ["/comm/mailnews/base/src/nsCidProtocolHandler.h"],
|
||||
"protocol_config": {
|
||||
"scheme": "cid",
|
||||
"flags": [
|
||||
"URI_DANGEROUS_TO_LOAD"
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{b897da55-8256-4cf5-892b-32e77bc7c50b}",
|
||||
|
|
|
@ -20,15 +20,6 @@ NS_IMETHODIMP nsCidProtocolHandler::GetScheme(nsACString& aScheme) {
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCidProtocolHandler::GetDefaultPort(int32_t* aDefaultPort) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCidProtocolHandler::GetProtocolFlags(uint32_t* aProtocolFlags) {
|
||||
// XXXbz so why does this protocol handler exist, exactly?
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult nsCidProtocolHandler::NewURI(const nsACString& aSpec,
|
||||
const char* aOriginCharset,
|
||||
nsIURI* aBaseURI, nsIURI** _retval) {
|
||||
|
|
|
@ -14,14 +14,6 @@ class MailtoProtocolHandler {
|
|||
|
||||
scheme = "mailto";
|
||||
allowPort = false;
|
||||
defaultPort = -1;
|
||||
protocolFlags =
|
||||
Ci.nsIProtocolHandler.URI_NORELATIVE |
|
||||
Ci.nsIProtocolHandler.ALLOWS_PROXY |
|
||||
Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE |
|
||||
Ci.nsIProtocolHandler.URI_NON_PERSISTABLE |
|
||||
Ci.nsIProtocolHandler.URI_DOES_NOT_RETURN_DATA |
|
||||
Ci.nsIProtocolHandler.URI_FORBIDS_COOKIE_ACCESS;
|
||||
|
||||
newChannel(uri, loadInfo) {
|
||||
// Create an empty pipe to get an inputStream.
|
||||
|
|
|
@ -4,43 +4,36 @@
|
|||
|
||||
var EXPORTED_SYMBOLS = ["SMTPProtocolHandler", "SMTPSProtocolHandler"];
|
||||
|
||||
var nsIProtocolHandler = Ci.nsIProtocolHandler;
|
||||
/**
|
||||
* @implements {nsIProtocolHandler}
|
||||
*/
|
||||
class SMTPProtocolHandler {
|
||||
QueryInterface = ChromeUtils.generateQI(["nsIProtocolHandler"]);
|
||||
|
||||
function makeProtocolHandler(aProtocol, aDefaultPort, aClassID) {
|
||||
return {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIProtocolHandler"]),
|
||||
|
||||
scheme: aProtocol,
|
||||
defaultPort: aDefaultPort,
|
||||
protocolFlags:
|
||||
nsIProtocolHandler.URI_NORELATIVE |
|
||||
nsIProtocolHandler.URI_DANGEROUS_TO_LOAD |
|
||||
nsIProtocolHandler.URI_NON_PERSISTABLE |
|
||||
nsIProtocolHandler.ALLOWS_PROXY |
|
||||
nsIProtocolHandler.URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT,
|
||||
scheme = "smtp";
|
||||
|
||||
newChannel(aURI, aLoadInfo) {
|
||||
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
|
||||
},
|
||||
|
||||
allowPort(port, scheme) {
|
||||
return port == aDefaultPort;
|
||||
},
|
||||
};
|
||||
throw Components.Exception(
|
||||
`${this.constructor.name}.newChannel not implemented`,
|
||||
Cr.NS_ERROR_NOT_IMPLEMENTED
|
||||
);
|
||||
}
|
||||
|
||||
function SMTPProtocolHandler() {}
|
||||
|
||||
SMTPProtocolHandler.prototype = makeProtocolHandler(
|
||||
"smtp",
|
||||
Ci.nsISmtpUrl.DEFAULT_SMTP_PORT,
|
||||
"b14c2b67-8680-4c11-8d63-9403c7d4f757"
|
||||
allowPort(port, scheme) {
|
||||
return port == Ci.nsISmtpUrl.DEFAULT_SMTP_PORT;
|
||||
}
|
||||
}
|
||||
SMTPProtocolHandler.prototype.classID = Components.ID(
|
||||
"{b14c2b67-8680-4c11-8d63-9403c7d4f757}"
|
||||
);
|
||||
|
||||
function SMTPSProtocolHandler() {}
|
||||
class SMTPSProtocolHandler extends SMTPProtocolHandler {
|
||||
scheme = "smtps";
|
||||
|
||||
SMTPSProtocolHandler.prototype = makeProtocolHandler(
|
||||
"smtps",
|
||||
Ci.nsISmtpUrl.DEFAULT_SMTPS_PORT,
|
||||
"057d0997-9e3a-411e-b4ee-2602f53fe05f"
|
||||
allowPort(port, scheme) {
|
||||
return port == Ci.nsISmtpUrl.DEFAULT_SMTPS_PORT;
|
||||
}
|
||||
}
|
||||
SMTPSProtocolHandler.prototype.classID = Components.ID(
|
||||
"{057d0997-9e3a-411e-b4ee-2602f53fe05f}"
|
||||
);
|
||||
|
|
|
@ -134,18 +134,51 @@ Classes = [
|
|||
"contract_ids": ["@mozilla.org/network/protocol;1?name=smtp"],
|
||||
"jsm": "resource:///modules/SMTPProtocolHandler.jsm",
|
||||
"constructor": "SMTPProtocolHandler",
|
||||
"protocol_config": {
|
||||
"scheme": "smtp",
|
||||
"flags": [
|
||||
"URI_NORELATIVE",
|
||||
"URI_DANGEROUS_TO_LOAD",
|
||||
"ALLOWS_PROXY",
|
||||
"URI_NON_PERSISTABLE",
|
||||
"URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT",
|
||||
],
|
||||
"default_port": 25,
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{057d0997-9e3a-411e-b4ee-2602f53fe05f}",
|
||||
"contract_ids": ["@mozilla.org/network/protocol;1?name=smtps"],
|
||||
"jsm": "resource:///modules/SMTPProtocolHandler.jsm",
|
||||
"constructor": "SMTPSProtocolHandler",
|
||||
"protocol_config": {
|
||||
"scheme": "smtps",
|
||||
"flags": [
|
||||
"URI_NORELATIVE",
|
||||
"URI_DANGEROUS_TO_LOAD",
|
||||
"ALLOWS_PROXY",
|
||||
"URI_NON_PERSISTABLE",
|
||||
"URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT",
|
||||
],
|
||||
"default_port": 465,
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{af314bd9-0b28-4f69-9bea-592ab4dc6811}",
|
||||
"contract_ids": ["@mozilla.org/network/protocol;1?name=mailto"],
|
||||
"jsm": "resource:///modules/MailtoProtocolHandler.jsm",
|
||||
"constructor": "MailtoProtocolHandler",
|
||||
"protocol_config": {
|
||||
"scheme": "mailto",
|
||||
"flags": [
|
||||
"URI_NORELATIVE",
|
||||
"ALLOWS_PROXY",
|
||||
"URI_LOADABLE_BY_ANYONE",
|
||||
"URI_NON_PERSISTABLE",
|
||||
"URI_DOES_NOT_RETURN_DATA",
|
||||
"URI_FORBIDS_COOKIE_ACCESS",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{acda6039-8b17-46c1-a8ed-ad50aa80f412}",
|
||||
|
|
|
@ -32,8 +32,11 @@ function run_test() {
|
|||
].createInstance(Ci.nsIProtocolHandler);
|
||||
|
||||
Assert.equal(pH.scheme, protocols[part].protocol);
|
||||
Assert.equal(pH.defaultPort, protocols[part].defaultPort);
|
||||
Assert.equal(pH.protocolFlags, defaultProtocolFlags);
|
||||
Assert.equal(
|
||||
Services.io.getDefaultPort(pH.scheme),
|
||||
protocols[part].defaultPort
|
||||
);
|
||||
Assert.equal(Services.io.getProtocolFlags(pH.scheme), defaultProtocolFlags);
|
||||
|
||||
// Whip through some of the ports to check we get the right results.
|
||||
for (let i = 0; i < 1024; ++i) {
|
||||
|
|
|
@ -82,6 +82,24 @@ ImapModuleLoader.prototype = {
|
|||
}
|
||||
|
||||
dump("[ImapModuleLoader] Using ImapService.jsm\n");
|
||||
|
||||
const { ImapProtocolHandler } = ChromeUtils.import(
|
||||
`resource:///modules/ImapProtocolHandler.jsm`
|
||||
);
|
||||
let protocolFlags =
|
||||
Ci.nsIProtocolHandler.URI_NORELATIVE |
|
||||
Ci.nsIProtocolHandler.URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT |
|
||||
Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD |
|
||||
Ci.nsIProtocolHandler.ALLOWS_PROXY |
|
||||
Ci.nsIProtocolHandler.URI_FORBIDS_COOKIE_ACCESS |
|
||||
Ci.nsIProtocolHandler.ORIGIN_IS_FULL_SPEC;
|
||||
|
||||
Services.io.registerProtocolHandler(
|
||||
"imap",
|
||||
new ImapProtocolHandler(),
|
||||
protocolFlags,
|
||||
Ci.nsIImapUrl.DEFAULT_IMAP_PORT
|
||||
);
|
||||
} else {
|
||||
dump("[ImapModuleLoader] Using nsImapService.cpp\n");
|
||||
}
|
||||
|
|
|
@ -13,14 +13,6 @@ class ImapProtocolHandler {
|
|||
QueryInterface = ChromeUtils.generateQI(["nsIProtocolHandler"]);
|
||||
|
||||
scheme = "imap";
|
||||
defaultPort = Ci.nsIImapUrl.DEFAULT_IMAP_PORT;
|
||||
protocolFlags =
|
||||
Ci.nsIProtocolHandler.URI_NORELATIVE |
|
||||
Ci.nsIProtocolHandler.URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT |
|
||||
Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD |
|
||||
Ci.nsIProtocolHandler.ALLOWS_PROXY |
|
||||
Ci.nsIProtocolHandler.URI_FORBIDS_COOKIE_ACCESS |
|
||||
Ci.nsIProtocolHandler.ORIGIN_IS_FULL_SPEC;
|
||||
|
||||
newChannel(uri, loadInfo) {
|
||||
let channel = new ImapChannel(uri, loadInfo);
|
||||
|
|
|
@ -95,6 +95,18 @@ NS_IMPL_ISUPPORTS(nsImapService, nsIImapService, nsIMsgMessageService,
|
|||
nsImapService::nsImapService() {
|
||||
if (!gInitialized) {
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIIOService> ioServ = do_GetIOService();
|
||||
ioServ->RegisterProtocolHandler(
|
||||
"imap"_ns, this,
|
||||
nsIProtocolHandler::URI_NORELATIVE |
|
||||
nsIProtocolHandler::URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT |
|
||||
nsIProtocolHandler::URI_DANGEROUS_TO_LOAD |
|
||||
nsIProtocolHandler::ALLOWS_PROXY |
|
||||
nsIProtocolHandler::URI_FORBIDS_COOKIE_ACCESS |
|
||||
nsIProtocolHandler::ORIGIN_IS_FULL_SPEC,
|
||||
nsIImapUrl::DEFAULT_IMAP_PORT);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv) && prefBranch) {
|
||||
|
@ -2308,22 +2320,6 @@ NS_IMETHODIMP nsImapService::GetScheme(nsACString& aScheme) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapService::GetDefaultPort(int32_t* aDefaultPort) {
|
||||
NS_ENSURE_ARG_POINTER(aDefaultPort);
|
||||
*aDefaultPort = nsIImapUrl::DEFAULT_IMAP_PORT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapService::GetProtocolFlags(uint32_t* result) {
|
||||
*result = URI_NORELATIVE | URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT |
|
||||
URI_DANGEROUS_TO_LOAD | ALLOWS_PROXY | URI_FORBIDS_COOKIE_ACCESS
|
||||
#ifdef IS_ORIGIN_IS_FULL_SPEC_DEFINED
|
||||
| ORIGIN_IS_FULL_SPEC
|
||||
#endif
|
||||
;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapService::AllowPort(int32_t port, const char* scheme,
|
||||
bool* aRetVal) {
|
||||
// allow imap to run on any port
|
||||
|
@ -2340,15 +2336,13 @@ NS_IMETHODIMP nsImapService::GetDefaultDoBiff(bool* aDoBiff) {
|
|||
|
||||
NS_IMETHODIMP nsImapService::GetDefaultServerPort(bool isSecure,
|
||||
int32_t* aDefaultPort) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Return Secure IMAP Port if secure option chosen i.e., if isSecure is TRUE
|
||||
if (isSecure)
|
||||
*aDefaultPort = nsIImapUrl::DEFAULT_IMAPS_PORT;
|
||||
else
|
||||
rv = GetDefaultPort(aDefaultPort);
|
||||
*aDefaultPort = nsIImapUrl::DEFAULT_IMAP_PORT;
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// this method first tries to find an exact username and hostname match with the
|
||||
|
|
|
@ -37,8 +37,11 @@ function run_test() {
|
|||
].createInstance(Ci.nsIProtocolHandler);
|
||||
|
||||
Assert.equal(pH.scheme, protocols[part].protocol);
|
||||
Assert.equal(pH.defaultPort, protocols[part].defaultPort);
|
||||
Assert.equal(pH.protocolFlags, defaultProtocolFlags);
|
||||
Assert.equal(
|
||||
Services.io.getDefaultPort(pH.scheme),
|
||||
protocols[part].defaultPort
|
||||
);
|
||||
Assert.equal(Services.io.getProtocolFlags(pH.scheme), defaultProtocolFlags);
|
||||
|
||||
// Whip through some of the ports to check we get the right results.
|
||||
// IMAP allows connecting to any port.
|
||||
|
|
|
@ -13,12 +13,6 @@ class Pop3ProtocolHandler {
|
|||
QueryInterface = ChromeUtils.generateQI(["nsIProtocolHandler"]);
|
||||
|
||||
scheme = "pop3";
|
||||
defaultPort = Ci.nsIPop3URL.DEFAULT_POP3_PORT;
|
||||
protocolFlags =
|
||||
Ci.nsIProtocolHandler.URI_NORELATIVE |
|
||||
Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD |
|
||||
Ci.nsIProtocolHandler.ALLOWS_PROXY |
|
||||
Ci.nsIProtocolHandler.URI_FORBIDS_COOKIE_ACCESS;
|
||||
|
||||
newChannel(uri, loadInfo) {
|
||||
let channel = new Pop3Channel(uri, loadInfo);
|
||||
|
|
|
@ -34,6 +34,17 @@ Classes = [
|
|||
"contract_ids": ["@mozilla.org/network/protocol;1?name=pop"],
|
||||
"jsm": "resource:///modules/Pop3ProtocolHandler.jsm",
|
||||
"constructor": "Pop3ProtocolHandler",
|
||||
"protocol_config": {
|
||||
"scheme": "pop3",
|
||||
"flags": [
|
||||
"URI_NORELATIVE",
|
||||
"URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT",
|
||||
"URI_DANGEROUS_TO_LOAD",
|
||||
"ALLOWS_PROXY",
|
||||
"URI_FORBIDS_COOKIE_ACCESS",
|
||||
],
|
||||
"default_port": 110,
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{46efcb10-cb6d-11d2-8065-006008128c4e}",
|
||||
|
@ -57,6 +68,16 @@ Classes = [
|
|||
],
|
||||
"type": "nsMailboxService",
|
||||
"headers": ["/comm/mailnews/local/src/nsMailboxService.h"],
|
||||
"protocol_config": {
|
||||
"scheme": "mailbox",
|
||||
"flags": [
|
||||
"URI_NORELATIVE",
|
||||
"URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT",
|
||||
"URI_DANGEROUS_TO_LOAD",
|
||||
"URI_FORBIDS_COOKIE_ACCESS",
|
||||
"ORIGIN_IS_FULL_SPEC",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{d17e0e22-285b-4239-863c-2eebb008b5cd}",
|
||||
|
|
|
@ -471,12 +471,6 @@ NS_IMETHODIMP nsMailboxService::GetScheme(nsACString& aScheme) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMailboxService::GetDefaultPort(int32_t* aDefaultPort) {
|
||||
NS_ENSURE_ARG_POINTER(aDefaultPort);
|
||||
*aDefaultPort = -1; // mailbox doesn't use a port!!!!!
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMailboxService::AllowPort(int32_t port, const char* scheme,
|
||||
bool* _retval) {
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
@ -485,17 +479,6 @@ NS_IMETHODIMP nsMailboxService::AllowPort(int32_t port, const char* scheme,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMailboxService::GetProtocolFlags(uint32_t* result) {
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
*result = URI_NORELATIVE | URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT |
|
||||
URI_DANGEROUS_TO_LOAD | URI_FORBIDS_COOKIE_ACCESS
|
||||
#ifdef IS_ORIGIN_IS_FULL_SPEC_DEFINED
|
||||
| ORIGIN_IS_FULL_SPEC
|
||||
#endif
|
||||
;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMailboxService::NewURI(const nsACString& aSpec,
|
||||
const char* aOriginCharset, nsIURI* aBaseURI,
|
||||
nsIURI** _retval) {
|
||||
|
|
|
@ -28,8 +28,11 @@ function run_test() {
|
|||
].createInstance(Ci.nsIProtocolHandler);
|
||||
|
||||
Assert.equal(pH.scheme, protocols[part].protocol);
|
||||
Assert.equal(pH.defaultPort, protocols[part].defaultPort);
|
||||
Assert.equal(pH.protocolFlags, defaultProtocolFlags);
|
||||
Assert.equal(
|
||||
Services.io.getDefaultPort(pH.scheme),
|
||||
protocols[part].defaultPort
|
||||
);
|
||||
Assert.equal(Services.io.getProtocolFlags(pH.scheme), defaultProtocolFlags);
|
||||
|
||||
// Whip through some of the ports to check we get the right results.
|
||||
for (let i = 0; i < 1024; ++i) {
|
||||
|
|
|
@ -7,26 +7,12 @@ var EXPORTED_SYMBOLS = ["NewsProtocolHandler", "SnewsProtocolHandler"];
|
|||
var { NntpChannel } = ChromeUtils.import("resource:///modules/NntpChannel.jsm");
|
||||
|
||||
/**
|
||||
* A factory to create protocol handler.
|
||||
*
|
||||
* @param {string} scheme - The scheme of the protocol.
|
||||
* @param {number} defaultPort - The default port of the protocol.
|
||||
* @param {string} cid - The interface id of the created protocol handler.
|
||||
* @implements {nsIProtocolHandler}
|
||||
*/
|
||||
function makeProtocolHandler(scheme, defaultPort, cid) {
|
||||
return {
|
||||
QueryInterface: ChromeUtils.generateQI(["nsIProtocolHandler"]),
|
||||
classID: Components.ID(cid),
|
||||
class NewsProtocolHandler {
|
||||
QueryInterface = ChromeUtils.generateQI(["nsIProtocolHandler"]);
|
||||
|
||||
scheme,
|
||||
defaultPort,
|
||||
protocolFlags:
|
||||
Ci.nsIProtocolHandler.URI_NORELATIVE |
|
||||
Ci.nsIProtocolHandler.URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT |
|
||||
Ci.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE |
|
||||
Ci.nsIProtocolHandler.ALLOWS_PROXY |
|
||||
Ci.nsIProtocolHandler.URI_FORBIDS_COOKIE_ACCESS |
|
||||
Ci.nsIProtocolHandler.ORIGIN_IS_FULL_SPEC,
|
||||
scheme = "news";
|
||||
|
||||
newChannel(uri, loadInfo) {
|
||||
let channel = new NntpChannel(uri, loadInfo);
|
||||
|
@ -42,26 +28,19 @@ function makeProtocolHandler(scheme, defaultPort, cid) {
|
|||
channel.contentDisposition = Ci.nsIChannel.DISPOSITION_INLINE;
|
||||
}
|
||||
return channel;
|
||||
},
|
||||
}
|
||||
|
||||
allowPort(port, scheme) {
|
||||
return true;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function NewsProtocolHandler() {}
|
||||
|
||||
NewsProtocolHandler.prototype = makeProtocolHandler(
|
||||
"news",
|
||||
Ci.nsINntpUrl.DEFAULT_NNTP_PORT,
|
||||
}
|
||||
NewsProtocolHandler.prototype.classID = Components.ID(
|
||||
"{24220ecd-cb05-4676-8a47-fa1da7b86e6e}"
|
||||
);
|
||||
|
||||
function SnewsProtocolHandler() {}
|
||||
|
||||
SnewsProtocolHandler.prototype = makeProtocolHandler(
|
||||
"snews",
|
||||
Ci.nsINntpUrl.DEFAULT_NNTPS_PORT,
|
||||
class SnewsProtocolHandler extends NewsProtocolHandler {
|
||||
scheme = "snews";
|
||||
}
|
||||
SnewsProtocolHandler.prototype.classID = Components.ID(
|
||||
"{1895016d-5302-46a9-b3f5-9c47694d9eca}"
|
||||
);
|
||||
|
|
|
@ -46,12 +46,36 @@ Classes = [
|
|||
"contract_ids": ["@mozilla.org/network/protocol;1?name=news"],
|
||||
"jsm": "resource:///modules/NntpProtocolHandler.jsm",
|
||||
"constructor": "NewsProtocolHandler",
|
||||
"protocol_config": {
|
||||
"scheme": "news",
|
||||
"flags": [
|
||||
"URI_NORELATIVE",
|
||||
"URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT",
|
||||
"URI_LOADABLE_BY_ANYONE",
|
||||
"ALLOWS_PROXY",
|
||||
"URI_FORBIDS_COOKIE_ACCESS",
|
||||
"ORIGIN_IS_FULL_SPEC",
|
||||
],
|
||||
"default_port": 119,
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{1895016d-5302-46a9-b3f5-9c47694d9eca}",
|
||||
"contract_ids": ["@mozilla.org/network/protocol;1?name=snews"],
|
||||
"jsm": "resource:///modules/NntpProtocolHandler.jsm",
|
||||
"constructor": "SnewsProtocolHandler",
|
||||
"protocol_config": {
|
||||
"scheme": "snews",
|
||||
"flags": [
|
||||
"URI_NORELATIVE",
|
||||
"URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT",
|
||||
"URI_LOADABLE_BY_ANYONE",
|
||||
"ALLOWS_PROXY",
|
||||
"URI_FORBIDS_COOKIE_ACCESS",
|
||||
"ORIGIN_IS_FULL_SPEC",
|
||||
],
|
||||
"default_port": 563,
|
||||
},
|
||||
},
|
||||
{
|
||||
"cid": "{196b4b30-e18c-11d2-806e-006008128c4e}",
|
||||
|
|
|
@ -33,8 +33,11 @@ function run_test() {
|
|||
].createInstance(Ci.nsIProtocolHandler);
|
||||
|
||||
Assert.equal(pH.scheme, protocols[part].protocol);
|
||||
Assert.equal(pH.defaultPort, protocols[part].defaultPort);
|
||||
Assert.equal(pH.protocolFlags, defaultProtocolFlags);
|
||||
Assert.equal(
|
||||
Services.io.getDefaultPort(pH.scheme),
|
||||
protocols[part].defaultPort
|
||||
);
|
||||
Assert.equal(Services.io.getProtocolFlags(pH.scheme), defaultProtocolFlags);
|
||||
|
||||
// Whip through some of the ports to check we get the right results.
|
||||
// NEWS allows connecting to any port.
|
||||
|
|
Загрузка…
Ссылка в новой задаче