Bug 1971140 - Improve Content-Disposition: attachment handling for object/embed, r=smaug a=dmeehan

Differential Revision: https://phabricator.services.mozilla.com/D253075
This commit is contained in:
Nika Layzell
2025-06-10 17:13:39 +00:00
committed by dmeehan@mozilla.com
parent 2b7bee41af
commit 7bfb0e8915
11 changed files with 177 additions and 145 deletions

View File

@@ -10795,11 +10795,14 @@ static nsresult AppendSegmentToString(nsIInputStream* aIn, void* aClosure,
openFlags |= nsIURILoader::DONT_RETARGET;
}
// Unless the pref is set, object/embed loads always specify DONT_RETARGET.
// See bug 1868001 for details.
if (!aIsDocumentLoad &&
!StaticPrefs::dom_navigation_object_embed_allow_retargeting()) {
openFlags |= nsIURILoader::DONT_RETARGET;
if (!aIsDocumentLoad) {
openFlags |= nsIURILoader::IS_OBJECT_EMBED;
// Unless the pref is set, object/embed loads always specify DONT_RETARGET.
// See bug 1868001 for details.
if (!StaticPrefs::dom_navigation_object_embed_allow_retargeting()) {
openFlags |= nsIURILoader::DONT_RETARGET;
}
}
return openFlags;
@@ -10890,8 +10893,14 @@ nsresult nsDocShell::OpenRedirectedChannel(nsDocShellLoadState* aLoadState) {
// ClientInfo, so we just need to allocate a corresponding ClientSource.
CreateReservedSourceIfNeeded(channel, GetMainThreadSerialEventTarget());
uint32_t documentOpenInfoFlags = nsIURILoader::DONT_RETARGET;
if (loadInfo->GetExternalContentPolicyType() ==
ExtContentPolicy::TYPE_OBJECT) {
documentOpenInfoFlags |= nsIURILoader::IS_OBJECT_EMBED;
}
RefPtr<nsDocumentOpenInfo> loader =
new nsDocumentOpenInfo(this, nsIURILoader::DONT_RETARGET, nullptr);
new nsDocumentOpenInfo(this, documentOpenInfoFlags, nullptr);
channel->SetLoadGroup(mLoadGroup);
MOZ_ALWAYS_SUCCEEDS(loader->Prepare());