Bug 389508: Cross site XMLHttpRequest. r=jst/biesi sr/dveditz/biesi

git-svn-id: svn://10.0.0.236/trunk@231095 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jonas%sicking.cc
2007-07-27 02:49:19 +00:00
parent 7509b39f4e
commit 857bbdaa67
18 changed files with 1435 additions and 1010 deletions

View File

@@ -1964,6 +1964,10 @@ nsHTMLDocument::GetCookie(nsAString& aCookie)
aCookie.Truncate(); // clear current cookie in case service fails;
// no cookie isn't an error condition.
if (mDisableCookieAccess) {
return NS_OK;
}
// not having a cookie service isn't an error
nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
if (service) {
@@ -1990,6 +1994,10 @@ nsHTMLDocument::GetCookie(nsAString& aCookie)
NS_IMETHODIMP
nsHTMLDocument::SetCookie(const nsAString& aCookie)
{
if (mDisableCookieAccess) {
return NS_OK;
}
// not having a cookie service isn't an error
nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
if (service && mDocumentURI) {

View File

@@ -207,6 +207,11 @@ public:
return mEditingState != eOff;
}
virtual void DisableCookieAccess()
{
mDisableCookieAccess = PR_TRUE;
}
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsHTMLDocument, nsDocument)
protected:
@@ -389,6 +394,8 @@ protected:
// XXXbz should this be reset if someone manually calls
// SetContentType() on this document?
PRInt32 mDefaultNamespaceID;
PRBool mDisableCookieAccess;
};
#endif /* nsHTMLDocument_h___ */

View File

@@ -152,6 +152,11 @@ public:
*/
virtual nsresult GetDocumentAllResult(const nsAString& aID,
nsISupports** aResult) = 0;
/**
* Disables getting and setting cookies
*/
virtual void DisableCookieAccess() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLDocument, NS_IHTMLDOCUMENT_IID)