From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- netwerk/protocol/res/SubstitutingProtocolHandler.cpp | 8 ++++---- netwerk/protocol/res/SubstitutingProtocolHandler.h | 12 ++++++------ netwerk/protocol/res/nsResProtocolHandler.cpp | 17 ++++++++++------- netwerk/protocol/res/nsResProtocolHandler.h | 8 ++------ 4 files changed, 22 insertions(+), 23 deletions(-) (limited to 'netwerk/protocol/res') diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp index 523aaa435d..a7d87b9fb2 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp @@ -437,7 +437,7 @@ nsresult SubstitutingProtocolHandler::NewURI(const nsACString& aSpec, // "android" is the only root that would return the RESOLVE_JAR_URI flag // see nsResProtocolHandler::GetSubstitutionInternal - if (MustResolveJAR(host)) { + if (GetJARFlags(host) & nsISubstitutingProtocolHandler::RESOLVE_JAR_URI) { return ResolveJARURI(uri, aResult); } @@ -599,8 +599,7 @@ nsresult SubstitutingProtocolHandler::GetSubstitution( } } - uint32_t flags; - return GetSubstitutionInternal(root, result, &flags); + return GetSubstitutionInternal(root, result); } nsresult SubstitutingProtocolHandler::GetSubstitutionFlags( @@ -625,7 +624,8 @@ nsresult SubstitutingProtocolHandler::GetSubstitutionFlags( } nsCOMPtr baseURI; - return GetSubstitutionInternal(root, getter_AddRefs(baseURI), flags); + *flags = GetJARFlags(root); + return GetSubstitutionInternal(root, getter_AddRefs(baseURI)); } nsresult SubstitutingProtocolHandler::HasSubstitution( diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.h b/netwerk/protocol/res/SubstitutingProtocolHandler.h index 6bdb27f38a..1d3033a5a0 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.h +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.h @@ -58,9 +58,8 @@ class SubstitutingProtocolHandler { // Override this in the subclass to try additional lookups after checking // mSubstitutions. [[nodiscard]] virtual nsresult GetSubstitutionInternal( - const nsACString& aRoot, nsIURI** aResult, uint32_t* aFlags) { + const nsACString& aRoot, nsIURI** aResult) { *aResult = nullptr; - *aFlags = 0; return NS_ERROR_NOT_AVAILABLE; } @@ -73,10 +72,11 @@ class SubstitutingProtocolHandler { return false; } - // This method should only return true if GetSubstitutionInternal would - // return the RESOLVE_JAR_URI flag. - [[nodiscard]] virtual bool MustResolveJAR(const nsACString& aRoot) { - return false; + // This method should only return RESOLVE_JAR_URI when + // GetSubstitutionalInternal will return nsIJARURI instead of a nsIFileURL. + // Currently, this only happens on Android. + [[nodiscard]] virtual uint32_t GetJARFlags(const nsACString& aRoot) { + return 0; } // Override this in the subclass to check for special case when opening diff --git a/netwerk/protocol/res/nsResProtocolHandler.cpp b/netwerk/protocol/res/nsResProtocolHandler.cpp index 208baedf2b..568f929f35 100644 --- a/netwerk/protocol/res/nsResProtocolHandler.cpp +++ b/netwerk/protocol/res/nsResProtocolHandler.cpp @@ -123,20 +123,23 @@ nsResProtocolHandler::AllowContentToAccess(nsIURI* aURI, bool* aResult) { return NS_OK; } +uint32_t nsResProtocolHandler::GetJARFlags(const nsACString& aRoot) { + if (aRoot.Equals(kAndroid)) { + return nsISubstitutingProtocolHandler::RESOLVE_JAR_URI; + } + + // 0 implies no content access. + return 0; +} + nsresult nsResProtocolHandler::GetSubstitutionInternal(const nsACString& aRoot, - nsIURI** aResult, - uint32_t* aFlags) { + nsIURI** aResult) { nsAutoCString uri; if (!ResolveSpecialCases(aRoot, "/"_ns, "/"_ns, uri)) { return NS_ERROR_NOT_AVAILABLE; } - if (aRoot.Equals(kAndroid)) { - *aFlags = nsISubstitutingProtocolHandler::RESOLVE_JAR_URI; - } else { - *aFlags = 0; // No content access. - } return NS_NewURI(aResult, uri); } diff --git a/netwerk/protocol/res/nsResProtocolHandler.h b/netwerk/protocol/res/nsResProtocolHandler.h index 50e790a53a..3c3781ac67 100644 --- a/netwerk/protocol/res/nsResProtocolHandler.h +++ b/netwerk/protocol/res/nsResProtocolHandler.h @@ -48,9 +48,9 @@ class nsResProtocolHandler final } protected: + [[nodiscard]] uint32_t GetJARFlags(const nsACString& aRoot) override; [[nodiscard]] nsresult GetSubstitutionInternal(const nsACString& aRoot, - nsIURI** aResult, - uint32_t* aFlags) override; + nsIURI** aResult) override; virtual ~nsResProtocolHandler() = default; [[nodiscard]] bool ResolveSpecialCases(const nsACString& aHost, @@ -58,10 +58,6 @@ class nsResProtocolHandler final const nsACString& aPathname, nsACString& aResult) override; - [[nodiscard]] virtual bool MustResolveJAR(const nsACString& aRoot) override { - return aRoot.EqualsLiteral("android"); - } - private: [[nodiscard]] nsresult Init(); static mozilla::StaticRefPtr sSingleton; -- cgit v1.2.3