tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit e2e91539047e030b956e01fd5e8c28c074ae3f88
parent afa632d8ef0c12f07ee3b36574e53f505ce256fe
Author: Serban Stanca <sstanca@mozilla.com>
Date:   Thu, 16 Oct 2025 05:55:32 +0300

Revert "Bug 1994472: Strip Content-Encoding when saving a cache item that's a dictionary r=necko-reviewers,valentin,kershaw" for causing wpt assertion failures in HttpBaseChannel.cpp.

This reverts commit e810283b0d941c394cfc63e8ad3efdf93da282b0.

Diffstat:
Mnetwerk/protocol/http/HttpBaseChannel.cpp | 25+++++++++++++++++--------
Mnetwerk/protocol/http/nsHttpChannel.cpp | 13-------------
2 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -1521,6 +1521,7 @@ HttpBaseChannel::DoApplyContentConversions(nsIStreamListener* aNextListener, char* cePtr = contentEncoding.BeginWriting(); uint32_t count = 0; + bool removeEncodings = false; while (char* val = nsCRT::strtok(cePtr, HTTP_LWS ",", &cePtr)) { if (++count > 16) { // For compatibility with old code, we will just carry on without @@ -1562,15 +1563,8 @@ HttpBaseChannel::DoApplyContentConversions(nsIStreamListener* aNextListener, } if (from.EqualsLiteral("dcb") || from.EqualsLiteral("dcz")) { MOZ_ASSERT(XRE_IsParentProcess()); + removeEncodings = true; } - // dcb and dcz encodings are removed when it's decompressed (always in - // the parent process). However, in theory you could have - // Content-Encoding: dcb,gzip - // in which case we could pass it down to the content process as - // Content-Encoding: gzip. We won't do that; we'll remove all - // compressors if we need to remove any. This double compression of course - // is silly, but supported by the spec. - nextListener = converter; } else { if (val) { @@ -1582,6 +1576,21 @@ HttpBaseChannel::DoApplyContentConversions(nsIStreamListener* aNextListener, } } + // dcb and dcz encodings are removed when it's decompressed (always in + // the parent process). However, in theory you could have + // Content-Encoding: dcb,gzip + // in which case we could pass it down to the content process as + // Content-Encoding: gzip. We won't do that; we'll remove all compressors + // if we need to remove any. + // This double compression of course is silly, but supported by the spec. + if (removeEncodings) { + // if we have dcb or dcz, all content-encodings in the header should + // be removed as we're decompressing before the tee in the parent + // process + LOG(("Changing Content-Encoding from '%s' to ''", contentEncoding.get())); + // Can't use SetHeader; we need to overwrite the current value + rv = mResponseHead->SetHeaderOverride(nsHttp::Content_Encoding, ""_ns); + } *aNewNextListener = do_AddRef(nextListener).take(); return NS_OK; } diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp @@ -6310,19 +6310,6 @@ nsresult nsHttpChannel::DoInstallCacheListener(bool aIsDictionaryCompressed, if (NS_FAILED(rv)) { return rv; } - // if we have dcb or dcz or if this is Use-As-Dictionary, all - // content-encodings in the header should be removed as we're - // decompressing before the tee in the parent process - LOG( - ("Clearing Content-Encoding since we're dictionary-compressed or are " - "a dictionary")); - // Can't use SetHeader; we need to overwrite the current value - rv = mResponseHead->SetHeaderOverride(nsHttp::Content_Encoding, ""_ns); - if (NS_FAILED(rv)) { - mCacheEntry->AsyncDoom(nullptr); - return rv; - } - // Remove Available-Dictionary from Vary header if present. This // avoids us refusing to match on a future load, for example if this // dictionary was decoded from an earlier version using a dictionary