diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /dom/quota/StorageOriginAttributes.cpp | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/quota/StorageOriginAttributes.cpp')
-rw-r--r-- | dom/quota/StorageOriginAttributes.cpp | 50 |
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")) { |