1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "SanitizationUtils.h"
11 #include "mozilla/dom/quota/QuotaManager.h"
14 namespace mozilla::dom::quota
{
16 nsAutoCString
MakeSanitizedOriginCString(const nsACString
& aOrigin
) {
18 NS_ASSERTION(!strcmp(QuotaManager::kReplaceChars
,
19 FILE_ILLEGAL_CHARACTERS FILE_PATH_SEPARATOR
),
20 "Illegal file characters have changed!");
23 nsAutoCString res
{aOrigin
};
25 res
.ReplaceChar(QuotaManager::kReplaceChars
, '+');
30 nsAutoString
MakeSanitizedOriginString(const nsACString
& aOrigin
) {
31 // An origin string is ASCII-only, since it is obtained via
32 // nsIPrincipal::GetOrigin, which returns an ACString.
33 return NS_ConvertASCIItoUTF16(MakeSanitizedOriginCString(aOrigin
));
36 } // namespace mozilla::dom::quota