Changes

Jump to: navigation, search

Cross Site XMLHttpRequest

2,108 bytes added, 01:50, 24 January 2007
Suggested Implementation
== Suggested Implementation ==
A goal of the implementation is that it should be reusable for other things than XMLHttpRequest. For example document.load should be able to do the same cross-site loads with the same restrictions. As should XSLT and XBL.
One tricky aspect is that the access control information can show up in two places. Both as HTTP headers, and as PIs inside XML files. Because of this it is suggested that the implementation has two parts:
 
* An [http://lxr.mozilla.org/mozilla/source/netwerk/base/public/nsIRequestObserver.idl nsIRequestObserver] that checked the headers during onStartRequest. The observer is given the uri of the requesting page when created and if the page doesn't have access throws an exception thereby aborting the request. The observer act as a wrapper and forwards all calls to the existing nsIRequestObserver implementation (in the case of XMLHttpRequest the [http://lxr.mozilla.org/mozilla/source/content/base/src/nsXMLHttpRequest.cpp nsXMLHttpRequest] class).
 
* A flag in [http://lxr.mozilla.org/mozilla/source/parser/htmlparser/src/nsExpatDriver.cpp nsExpatDriver] that makes the driver not send any notifications to the sink until either it has passed the matched an access control PI, or it has reached the first element without finding a matching PI. If access should be denied the sink is canceled and we need to signal back to the XMLHttpRequest that loading failed.
 
Unfortunately gecko architecture forces us to create a document before we create an nsExpatDriver. In fact, I'm not sure there is a way to even know that an nsExpatDriver will be created other than by calling [http://lxr.mozilla.org/mozilla/source/content/base/public/nsIDocument.h#148 StartDocumentLoad] on the document. We could possibly set up a dummy document until we get word from the nsExpatDriver that the access checks were successful and if they are set up a real document and restart the load.
 
=== Issues ===
 
* If the check in onStartRequest fails, should we call the wrapping onStartRequest? The nsIRequestObserver interfaces says we must, but there is no way to indicate that the request is aborted.
== Security worries ==
Confirm
716
edits

Navigation menu