Fixing bug 253121. Make wyciwyg channels and documents carry the source channels security info. r=darin@meer.net, sr=bzbarsky@mit.edu, a=roc@ocallahan.org
git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_7_BRANCH@159950 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -725,6 +725,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Store the security info for future use with wyciwyg channels.
|
||||
aChannel->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
|
||||
|
||||
// Stash away a pointer to our channel (we need this for cookies)
|
||||
mChannel = aChannel;
|
||||
|
||||
@@ -2015,6 +2018,17 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURI)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> callingDoc =
|
||||
do_QueryInterface(nsContentUtils::GetDocumentFromCaller());
|
||||
|
||||
// Grab a reference to the calling documents security info (if any)
|
||||
// as it may be lost in the call to Reset().
|
||||
nsCOMPtr<nsISupports> securityInfo;
|
||||
|
||||
if (callingDoc) {
|
||||
securityInfo = callingDoc->GetSecurityInfo();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docshell = do_QueryReferent(mDocumentContainer);
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@@ -2120,6 +2134,10 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURI)
|
||||
mRootContent = root;
|
||||
}
|
||||
|
||||
// Store the security info of the caller now that we're done
|
||||
// resetting the document.
|
||||
mSecurityInfo = securityInfo;
|
||||
|
||||
mParser = do_CreateInstance(kCParserCID, &rv);
|
||||
|
||||
mIsWriting = 1;
|
||||
@@ -3499,11 +3517,14 @@ nsHTMLDocument::CreateAndAddWyciwygChannel(void)
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
// Create a wyciwyg Channel
|
||||
rv = NS_NewChannel(getter_AddRefs(channel), wcwgURI);
|
||||
if (NS_SUCCEEDED(rv) && channel) {
|
||||
mWyciwygChannel = do_QueryInterface(channel);
|
||||
// Inherit load flags from the original document's channel
|
||||
channel->SetLoadFlags(mLoadFlags);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mWyciwygChannel = do_QueryInterface(channel);
|
||||
|
||||
mWyciwygChannel->SetSecurityInfo(mSecurityInfo);
|
||||
|
||||
// Inherit load flags from the original document's channel
|
||||
channel->SetLoadFlags(mLoadFlags);
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = GetDocumentLoadGroup();
|
||||
|
||||
|
||||
@@ -229,7 +229,9 @@ nsWyciwygChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationC
|
||||
NS_IMETHODIMP
|
||||
nsWyciwygChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
NS_IF_ADDREF(*aSecurityInfo = mSecurityInfo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -330,6 +332,10 @@ nsWyciwygChannel::WriteToCacheEntry(const nsACString &aScript)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
if (mSecurityInfo) {
|
||||
mCacheEntry->SetSecurityInfo(mSecurityInfo);
|
||||
}
|
||||
|
||||
if (!mCacheOutputStream) {
|
||||
// Get the outputstream from the cache entry.
|
||||
rv = mCacheEntry->OpenOutputStream(0, getter_AddRefs(mCacheOutputStream));
|
||||
@@ -357,6 +363,14 @@ nsWyciwygChannel::CloseCacheEntry(nsresult reason)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWyciwygChannel::SetSecurityInfo(nsISupports *aSecurityInfo)
|
||||
{
|
||||
mSecurityInfo = aSecurityInfo;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// nsICachelistener
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -525,6 +539,9 @@ nsWyciwygChannel::ReadFromCache()
|
||||
NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_FAILURE);
|
||||
nsresult rv;
|
||||
|
||||
// Get the stored security info
|
||||
mCacheEntry->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
|
||||
|
||||
// Get a transport to the cached data...
|
||||
rv = mCacheEntry->OpenInputStream(0, getter_AddRefs(mCacheInputStream));
|
||||
if (NS_FAILED(rv))
|
||||
|
||||
@@ -90,6 +90,8 @@ protected:
|
||||
nsCOMPtr<nsICacheEntryDescriptor> mCacheEntry;
|
||||
nsCOMPtr<nsIOutputStream> mCacheOutputStream;
|
||||
nsCOMPtr<nsIInputStream> mCacheInputStream;
|
||||
|
||||
nsCOMPtr<nsISupports> mSecurityInfo;
|
||||
};
|
||||
|
||||
#endif /* nsWyciwygChannel_h___ */
|
||||
|
||||
Reference in New Issue
Block a user