diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /dom/quota/StorageOriginAttributes.cpp | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/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")) { |