From 752311fd47d24fe949aeabedbd8c9ffe25f740f4 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 31 Oct 2018 18:32:00 +0100 Subject: Origin for about: URL should not contain query or ref parts. --- caps/nsPrincipal.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'caps') diff --git a/caps/nsPrincipal.cpp b/caps/nsPrincipal.cpp index f890610430..129cdf9a05 100644 --- a/caps/nsPrincipal.cpp +++ b/caps/nsPrincipal.cpp @@ -161,6 +161,19 @@ nsPrincipal::GetOriginForURI(nsIURI* aURI, nsACString& aOrigin) (NS_SUCCEEDED(origin->SchemeIs("indexeddb", &isBehaved)) && isBehaved)) { rv = origin->GetAsciiSpec(aOrigin); NS_ENSURE_SUCCESS(rv, rv); + + // Remove query or ref part from about: origin + int32_t pos = aOrigin.FindChar('?'); + int32_t hashPos = aOrigin.FindChar('#'); + + if (hashPos != kNotFound && (pos == kNotFound || hashPos < pos)) { + pos = hashPos; + } + + if (pos != kNotFound) { + aOrigin.Truncate(pos); + } + // These URIs could technically contain a '^', but they never should. if (NS_WARN_IF(aOrigin.FindChar('^', 0) != -1)) { aOrigin.Truncate(); -- cgit v1.2.3