Bug 1706615 - Part 2: Add UnstrippedURI in the nsDocShellLoadState. r=smaug

This patch adds an attribute UnstrippedURI in the nsDocShellLoadState.
The attribute will be set if the query stripping was happening.
Otherwise, it will stay a nullptr. This attribute will be propagated to
the loadInfo, so that we can revert the query stripping in the parent
process if the loading URI is in the content blocking allow list. We can
only revert the query stripping in the parent process because we cannot
access the permission of the content blocking allow list of a
cross-origin domain. So, we can only carry the unstripped URI in the
loadInfo and perform a interal redirect to revert the query stripping.

Differential Revision: https://phabricator.services.mozilla.com/D116109
This commit is contained in:
Tim Huang 2021-06-02 19:46:20 +00:00
Родитель d7220a241a
Коммит 99cf3b886d
3 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -86,6 +86,7 @@ nsDocShellLoadState::nsDocShellLoadState(
mLoadingSessionHistoryInfo = MakeUnique<LoadingSessionHistoryInfo>(
aLoadState.loadingSessionHistoryInfo().ref());
}
mUnstrippedURI = aLoadState.UnstrippedURI();
}
nsDocShellLoadState::nsDocShellLoadState(const nsDocShellLoadState& aOther)
@ -130,7 +131,8 @@ nsDocShellLoadState::nsDocShellLoadState(const nsDocShellLoadState& aOther)
mCancelContentJSEpoch(aOther.mCancelContentJSEpoch),
mLoadIdentifier(aOther.mLoadIdentifier),
mChannelInitialized(aOther.mChannelInitialized),
mIsMetaRefresh(aOther.mIsMetaRefresh) {
mIsMetaRefresh(aOther.mIsMetaRefresh),
mUnstrippedURI(aOther.mUnstrippedURI) {
if (aOther.mLoadingSessionHistoryInfo) {
mLoadingSessionHistoryInfo = MakeUnique<LoadingSessionHistoryInfo>(
*aOther.mLoadingSessionHistoryInfo);
@ -1018,5 +1020,8 @@ DocShellLoadStateInit nsDocShellLoadState::Serialize() {
if (mLoadingSessionHistoryInfo) {
loadState.loadingSessionHistoryInfo().emplace(*mLoadingSessionHistoryInfo);
}
loadState.UnstrippedURI() = mUnstrippedURI;
return loadState;
}
nsIURI* nsDocShellLoadState::GetUnstrippedURI() const { return mUnstrippedURI; }

Просмотреть файл

@ -247,6 +247,8 @@ class nsDocShellLoadState final {
void SetFileName(const nsAString& aFileName);
nsIURI* GetUnstrippedURI() const;
// Give the type of DocShell we're loading into (chrome/content/etc) and
// origin attributes for the URI we're loading, figure out if we should
// inherit our principal from the document the load was requested from, or
@ -517,6 +519,10 @@ class nsDocShellLoadState final {
// True if the load was triggered by a meta refresh.
bool mIsMetaRefresh;
// The original URI before query stripping happened. If it's present, it shows
// the query stripping happened. Otherwise, it will be a nullptr.
nsCOMPtr<nsIURI> mUnstrippedURI;
};
#endif /* nsDocShellLoadState_h__ */

Просмотреть файл

@ -301,6 +301,8 @@ struct DocShellLoadStateInit
LoadingSessionHistoryInfo? loadingSessionHistoryInfo;
bool IsMetaRefresh;
nsIURI UnstrippedURI;
};
struct TimedChannelInfo