summaryrefslogtreecommitdiffstats
path: root/dom/quota/StorageOriginAttributes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/quota/StorageOriginAttributes.cpp')
-rw-r--r--dom/quota/StorageOriginAttributes.cpp50
1 files changed, 49 insertions, 1 deletions
diff --git a/dom/quota/StorageOriginAttributes.cpp b/dom/quota/StorageOriginAttributes.cpp
index 7d8fd9c802..bcdf47bce8 100644
--- a/dom/quota/StorageOriginAttributes.cpp
+++ b/dom/quota/StorageOriginAttributes.cpp
@@ -6,10 +6,58 @@
#include "StorageOriginAttributes.h"
+#include "nsString.h"
#include "nsURLHelper.h"
+#include "mozilla/Assertions.h"
+#include "mozilla/dom/quota/QuotaManager.h"
namespace mozilla {
+void StorageOriginAttributes::CreateSuffix(nsACString& aStr) const {
+ nsCString str1;
+
+ URLParams params;
+ nsAutoString value;
+
+ if (mInIsolatedMozBrowser) {
+ params.Set(u"inBrowser"_ns, u"1"_ns);
+ }
+
+ str1.Truncate();
+
+ params.Serialize(value, true);
+ if (!value.IsEmpty()) {
+ str1.AppendLiteral("^");
+ str1.Append(NS_ConvertUTF16toUTF8(value));
+ }
+
+ // Make sure that the string don't contain characters that would get replaced
+ // with the plus character by quota manager, potentially causing ambiguity.
+ MOZ_ASSERT(str1.FindCharInSet(dom::quota::QuotaManager::kReplaceChars) ==
+ kNotFound);
+
+ // Let OriginAttributes::CreateSuffix serialize other origin attributes.
+ nsCString str2;
+ mOriginAttributes.CreateSuffix(str2);
+
+ aStr.Truncate();
+
+ if (str1.IsEmpty()) {
+ aStr.Append(str2);
+ return;
+ }
+
+ if (str2.IsEmpty()) {
+ aStr.Append(str1);
+ return;
+ }
+
+ // If both strings are not empty, we need to combine them.
+ aStr.Append(str1);
+ aStr.Append('&');
+ aStr.Append(Substring(str2, 1, str2.Length() - 1));
+}
+
bool StorageOriginAttributes::PopulateFromSuffix(const nsACString& aStr) {
if (aStr.IsEmpty()) {
return true;
@@ -20,7 +68,7 @@ bool StorageOriginAttributes::PopulateFromSuffix(const nsACString& aStr) {
}
bool ok =
- URLParams::Parse(Substring(aStr, 1, aStr.Length() - 1),
+ URLParams::Parse(Substring(aStr, 1, aStr.Length() - 1), true,
[this](const nsAString& aName, const nsAString& aValue) {
if (aName.EqualsLiteral("inBrowser")) {
if (!aValue.EqualsLiteral("1")) {