Skip to content

Commit ddaf8ae

Browse files
committed
[DO NOT MERGE INTO 3.0] Remove nsIContentPolicy paths
These are obsolete as of Firefox 20, which ships the channel.redirectTo API. This should fix: https://bugzilla.mozilla.org/show_bug.cgi?id=939180
1 parent ce0cee0 commit ddaf8ae

3 files changed

Lines changed: 5 additions & 124 deletions

File tree

src/chrome/content/code/HTTPS.js

Lines changed: 2 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -87,104 +87,9 @@ const HTTPS = {
8787
IOUtil.abort(channel);
8888
return false;
8989
},
90-
91-
rewriteInPlace: function(old_uri, new_uri) {
92-
// Strategy 1: replace the parts of the old_uri piecewise. Often this
93-
// works. In some cases it doesn't.
94-
this.log(NOTE,"Rewriting " + old_uri.spec + " -> " + new_uri.spec + "\n");
9590

96-
old_uri.scheme = new_uri.scheme;
97-
old_uri.userPass = new_uri.userPass;
98-
old_uri.username = new_uri.username;
99-
if (new_uri.password)
100-
old_uri.password = new_uri.password;
101-
old_uri.host = new_uri.host;
102-
old_uri.port = new_uri.port;
103-
old_uri.path = new_uri.path;
104-
return true;
105-
},
106-
107-
getApplicableListForContext: function(ctx, uri) {
108-
var alist = null;
109-
var domWin = null;
110-
if (!ctx) {
111-
this.log(NOTE, "No context loading " + uri.spec);
112-
return null;
113-
}
114-
if (ctx instanceof CI.nsIDOMWindow) {
115-
domWin = ctx.QueryInterface(CI.nsIDOMWindow);
116-
doc = domWin.document;
117-
} else if (ctx instanceof CI.nsIDOMNode) {
118-
var doc = ctx.QueryInterface(CI.nsIDOMNode).ownerDocument;
119-
if (! doc) {
120-
this.log(NOTE, "No Document for request " + uri.spec);
121-
return null;
122-
}
123-
domWin = doc.defaultView;
124-
//this.log(DBUG,"Coerced nsIDOMWin from Node: " + domWin);
125-
} else {
126-
this.log(WARN, "Context for " + uri.spec +
127-
"is some bizarre unexpected thing: " + ctx);
128-
return null;
129-
}
130-
return HTTPSEverywhere.instance.getApplicableListForDOMWin(domWin, "for context/forceURI");
131-
},
132-
133-
forceURI: function(uri, fallback, ctx) {
134-
// Switch some uris to https; ctx is either nsIDOMNode or nsIDOMWindow as
135-
// per the ContentPolicy API.
136-
// Returns true if everything worked out (either correct replacement or no
137-
// replacement needed). Retun False if all attempts to rewrite failed.
138-
139-
// first of all we need to get the applicable rules list to keep track of
140-
// what rulesets might have applied to this page
141-
this.log(VERB, "Context is " + ctx);
142-
var alist = this.getApplicableListForContext(ctx, uri);
143-
var blob = HTTPSRules.rewrittenURI(alist, uri);
144-
if (null == blob) return true; // no applicable rule
145-
var newuri = blob.newuri;
146-
147-
try {
148-
HTTPSEverywhere.instance.notifyObservers(uri, newuri.spec);
149-
if (this.rewriteInPlace(uri, newuri))
150-
this.log(INFO,"Forced URI " + uri.spec);
151-
return true;
152-
} catch(e) {
153-
154-
if (ctx &&
155-
(ctx instanceof CI.nsIDOMHTMLImageElement
156-
|| ctx instanceof CI.nsIDOMHTMLInputElement
157-
|| ctx instanceof CI.nsIObjectLoadingContent)) {
158-
159-
var type, attr;
160-
if (ctx instanceof CI.nsIObjectLoadingContent) {
161-
type = "Object";
162-
attr = "data";
163-
} else {
164-
type = "Image";
165-
attr = "src";
166-
}
167-
// XXX Isn't this a security flaw? Have to bug Georgio about
168-
// this... the content policy docs claim to require it, but
169-
// it looks like a race condition nightmare.
170-
Thread.asap(function() { ctx.setAttribute(attr, newuri.spec); });
171-
172-
var msg = type + " HTTP->HTTPS redirection to " + newuri.spec;
173-
174-
this.log(INFO,msg);
175-
throw msg;
176-
}
177-
178-
if (fallback && fallback()) {
179-
this.log(INFO, "Channel redirection fallback on " + uri.spec);
180-
return true;
181-
}
182-
183-
this.log(WARN,"Firefox wouldn't set https on " + uri.spec);
184-
this.log(INFO,"(error was " + e + ")");
185-
}
186-
return false;
187-
},
91+
// getApplicableListForContext was remove along with the nsIContentPolicy
92+
// bindings and the and forceURI path that used them.
18893

18994
onCrossSiteRequest: function(channel, origin, browser, rw) {
19095
try {

src/components/https-everywhere.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,13 @@ HTTPSEverywhere.prototype = {
276276
{
277277
category: "app-startup",
278278
},
279-
{
280-
category: "content-policy",
281-
},
282279
],
283280

284281
// QueryInterface implementation, e.g. using the generateQI helper
285282
QueryInterface: XPCOMUtils.generateQI(
286283
[ Components.interfaces.nsIObserver,
287284
Components.interfaces.nsIMyInterface,
288285
Components.interfaces.nsISupports,
289-
Components.interfaces.nsIContentPolicy,
290286
Components.interfaces.nsISupportsWeakReference,
291287
Components.interfaces.nsIWebProgressListener,
292288
Components.interfaces.nsIWebProgressListener2,
@@ -604,26 +600,6 @@ HTTPSEverywhere.prototype = {
604600
callback.onRedirectVerifyCallback(0);
605601
},
606602

607-
// These implement the nsIContentPolicy API; they allow both yes/no answers
608-
// to "should this load?", but also allow us to change the thing.
609-
610-
shouldLoad: function(aContentType, aContentLocation, aRequestOrigin, aContext, aMimeTypeGuess, aInternalCall) {
611-
//this.log(WARN,"shouldLoad for " + unwrappedLocation.spec + " of type " + aContentType);
612-
if (shouldLoadTargets[aContentType] != null) {
613-
var unwrappedLocation = IOUtil.unwrapURL(aContentLocation);
614-
var scheme = unwrappedLocation.scheme;
615-
var isHTTP = /^https?$/.test(scheme); // s? -> either http or https
616-
this.log(VERB,"shoulLoad for " + aContentLocation.spec);
617-
if (isHTTP)
618-
HTTPS.forceURI(aContentLocation, null, aContext);
619-
}
620-
return true;
621-
},
622-
623-
shouldProcess: function(aContentType, aContentLocation, aRequestOrigin, aContext, aMimeType, aExtra) {
624-
return this.shouldLoad(aContentType, aContentLocation, aRequestOrigin, aContext, aMimeType, CP_SHOULDPROCESS);
625-
},
626-
627603
get_prefs: function(prefBranch) {
628604
if(!prefBranch) prefBranch = PREFBRANCH_ROOT;
629605

src/install.rdf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@
1919
<em:targetApplication>
2020
<Description>
2121
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
22-
<em:minVersion>3.5</em:minVersion>
22+
<em:minVersion>20</em:minVersion>
2323
<em:maxVersion>99.*</em:maxVersion>
2424
</Description>
2525
</em:targetApplication>
2626
<!-- Seamonkey -->
2727
<em:targetApplication>
2828
<Description>
2929
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
30-
<em:minVersion>2.0</em:minVersion>
30+
<em:minVersion>2.17</em:minVersion>
3131
<em:maxVersion>99.*</em:maxVersion>
3232
</Description>
3333
</em:targetApplication>
3434
<!-- thunderbird -->
3535
<em:targetApplication>
3636
<Description>
3737
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
38-
<em:minVersion>3.0</em:minVersion>
38+
<em:minVersion>17.0.5</em:minVersion>
3939
<em:maxVersion>99.*</em:maxVersion>
4040
</Description>
4141
</em:targetApplication>

0 commit comments

Comments
 (0)