зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1839417 - Move sanitization methods to separate files; r=dom-storage-reviewers,asuth
(needed for moving operations outside ActorsParent.cpp) Differential Revision: https://phabricator.services.mozilla.com/D181479
This commit is contained in:
Родитель
dc0856d1d0
Коммит
120b8693b5
|
@ -17,6 +17,7 @@
|
|||
#include "OriginInfo.h"
|
||||
#include "QuotaCommon.h"
|
||||
#include "QuotaManager.h"
|
||||
#include "SanitizationUtils.h"
|
||||
#include "ScopedLogExtraInfo.h"
|
||||
#include "UsageInfo.h"
|
||||
|
||||
|
@ -2113,26 +2114,6 @@ class RestoreDirectoryMetadata2Helper final : public StorageOperationBase {
|
|||
nsresult ProcessOriginDirectory(const OriginProps& aOriginProps) override;
|
||||
};
|
||||
|
||||
auto MakeSanitizedOriginCString(const nsACString& aOrigin) {
|
||||
#ifdef XP_WIN
|
||||
NS_ASSERTION(!strcmp(QuotaManager::kReplaceChars,
|
||||
FILE_ILLEGAL_CHARACTERS FILE_PATH_SEPARATOR),
|
||||
"Illegal file characters have changed!");
|
||||
#endif
|
||||
|
||||
nsAutoCString res{aOrigin};
|
||||
|
||||
res.ReplaceChar(QuotaManager::kReplaceChars, '+');
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
auto MakeSanitizedOriginString(const nsACString& aOrigin) {
|
||||
// An origin string is ASCII-only, since it is obtained via
|
||||
// nsIPrincipal::GetOrigin, which returns an ACString.
|
||||
return NS_ConvertASCIItoUTF16(MakeSanitizedOriginCString(aOrigin));
|
||||
}
|
||||
|
||||
Result<nsAutoString, nsresult> GetPathForStorage(
|
||||
nsIFile& aBaseDir, const nsAString& aStorageName) {
|
||||
QM_TRY_INSPECT(const auto& storageDir,
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SanitizationUtils.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla::dom::quota {
|
||||
|
||||
nsAutoCString MakeSanitizedOriginCString(const nsACString& aOrigin) {
|
||||
#ifdef XP_WIN
|
||||
NS_ASSERTION(!strcmp(QuotaManager::kReplaceChars,
|
||||
FILE_ILLEGAL_CHARACTERS FILE_PATH_SEPARATOR),
|
||||
"Illegal file characters have changed!");
|
||||
#endif
|
||||
|
||||
nsAutoCString res{aOrigin};
|
||||
|
||||
res.ReplaceChar(QuotaManager::kReplaceChars, '+');
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsAutoString MakeSanitizedOriginString(const nsACString& aOrigin) {
|
||||
// An origin string is ASCII-only, since it is obtained via
|
||||
// nsIPrincipal::GetOrigin, which returns an ACString.
|
||||
return NS_ConvertASCIItoUTF16(MakeSanitizedOriginCString(aOrigin));
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom::quota
|
|
@ -0,0 +1,20 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef DOM_QUOTA_SANITIZATIONUTILS_H_
|
||||
#define DOM_QUOTA_SANITIZATIONUTILS_H_
|
||||
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
namespace mozilla::dom::quota {
|
||||
|
||||
nsAutoCString MakeSanitizedOriginCString(const nsACString& aOrigin);
|
||||
|
||||
nsAutoString MakeSanitizedOriginString(const nsACString& aOrigin);
|
||||
|
||||
} // namespace mozilla::dom::quota
|
||||
|
||||
#endif // DOM_QUOTA_SANITIZATIONUTILS_H_
|
|
@ -100,6 +100,7 @@ UNIFIED_SOURCES += [
|
|||
"RemoteQuotaObject.cpp",
|
||||
"RemoteQuotaObjectChild.cpp",
|
||||
"RemoteQuotaObjectParent.cpp",
|
||||
"SanitizationUtils.cpp",
|
||||
"ScopedLogExtraInfo.cpp",
|
||||
"StorageHelpers.cpp",
|
||||
"StorageManager.cpp",
|
||||
|
|
Загрузка…
Ссылка в новой задаче