summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-03-03 22:38:31 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-03-03 22:39:11 +0100
commitbba13e3d3404473373d9d2122608a90e0aa2ca9f (patch)
tree7854be02a408af845635a2b26c6ad9cf65245b4e
parent9626500a0ecefde76411b60aeb54051cfdbc90c4 (diff)
parentc1ba23a015a2e85b2290a1cdfb0d697381b3cd2a (diff)
downloadUXP-bba13e3d3404473373d9d2122608a90e0aa2ca9f.tar
UXP-bba13e3d3404473373d9d2122608a90e0aa2ca9f.tar.gz
UXP-bba13e3d3404473373d9d2122608a90e0aa2ca9f.tar.lz
UXP-bba13e3d3404473373d9d2122608a90e0aa2ca9f.tar.xz
UXP-bba13e3d3404473373d9d2122608a90e0aa2ca9f.zip
Merge branch '_native_52ESR_dom_url_origin_ref_1'
This resolves #38
-rw-r--r--caps/nsPrincipal.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/caps/nsPrincipal.cpp b/caps/nsPrincipal.cpp
index 4cb472369..f89061043 100644
--- a/caps/nsPrincipal.cpp
+++ b/caps/nsPrincipal.cpp
@@ -184,8 +184,23 @@ nsPrincipal::GetOriginForURI(nsIURI* aURI, nsACString& aOrigin)
// origin string
nsCOMPtr<nsIStandardURL> standardURL = do_QueryInterface(origin);
NS_ENSURE_TRUE(standardURL, NS_ERROR_FAILURE);
+
rv = origin->GetAsciiSpec(aOrigin);
NS_ENSURE_SUCCESS(rv, rv);
+
+ // The origin, when taken from the spec, should not contain the ref part of
+ // the URL.
+
+ 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);
+ }
}
return NS_OK;