@@ -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 {
0 commit comments