summaryrefslogtreecommitdiffstats
path: root/caps/nsPrincipal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'caps/nsPrincipal.cpp')
-rw-r--r--caps/nsPrincipal.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/caps/nsPrincipal.cpp b/caps/nsPrincipal.cpp
index f89061043..d111042c1 100644
--- a/caps/nsPrincipal.cpp
+++ b/caps/nsPrincipal.cpp
@@ -19,6 +19,8 @@
#include "nsJSPrincipals.h"
#include "nsIEffectiveTLDService.h"
#include "nsIClassInfoImpl.h"
+#include "nsIObjectInputStream.h"
+#include "nsIObjectOutputStream.h"
#include "nsIProtocolHandler.h"
#include "nsError.h"
#include "nsIContentSecurityPolicy.h"
@@ -161,6 +163,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();