Bug 1679987 - Use nsTokenizedRange where easily possible. r=xpcom-reviewers,nika

Differential Revision: https://phabricator.services.mozilla.com/D98308
This commit is contained in:
Simon Giesecke 2020-12-16 19:10:34 +00:00
Родитель 4a023dd2aa
Коммит 9379d0240f
31 изменённых файлов: 92 добавлений и 153 удалений

Просмотреть файл

@ -123,10 +123,9 @@ class MOZ_STACK_CLASS FormDataParser {
}
if (headerName.LowerCaseEqualsLiteral("content-disposition")) {
nsCCharSeparatedTokenizer tokenizer(headerValue, ';');
bool seenFormData = false;
while (tokenizer.hasMoreTokens()) {
const nsDependentCSubstring& token = tokenizer.nextToken();
for (const nsACString& token :
nsCCharSeparatedTokenizer(headerValue, ';').ToRange()) {
if (token.IsEmpty()) {
continue;
}

Просмотреть файл

@ -335,10 +335,8 @@ void Navigator::GetAcceptLanguages(nsTArray<nsString>& aLanguages) {
Preferences::GetLocalizedString("intl.accept_languages", acceptLang);
// Split values on commas.
nsCharSeparatedTokenizer langTokenizer(acceptLang, ',');
while (langTokenizer.hasMoreTokens()) {
nsDependentSubstring lang = langTokenizer.nextToken();
for (nsDependentSubstring lang :
nsCharSeparatedTokenizer(acceptLang, ',').ToRange()) {
// Replace "_" with "-" to avoid POSIX/Windows "en_US" notation.
// NOTE: we should probably rely on the pref being set correctly.
if (lang.Length() > 2 && lang[2] == char16_t('_')) {
@ -349,12 +347,10 @@ void Navigator::GetAcceptLanguages(nsTArray<nsString>& aLanguages) {
// only uppercase 2-letter country codes, not "zh-Hant", "de-DE-x-goethe".
// NOTE: we should probably rely on the pref being set correctly.
if (lang.Length() > 2) {
nsCharSeparatedTokenizer localeTokenizer(lang, '-');
int32_t pos = 0;
bool first = true;
while (localeTokenizer.hasMoreTokens()) {
const nsAString& code = localeTokenizer.nextToken();
for (const nsAString& code :
nsCharSeparatedTokenizer(lang, '-').ToRange()) {
if (code.Length() == 2 && !first) {
nsAutoString upper(code);
ToUpperCase(upper);

Просмотреть файл

@ -520,9 +520,8 @@ already_AddRefed<InternalHeaders> InternalHeaders::CORSHeaders(
bool allowAllHeaders = false;
AutoTArray<nsCString, 5> exposeNamesArray;
nsCCharSeparatedTokenizer exposeTokens(acExposedNames, ',');
while (exposeTokens.hasMoreTokens()) {
const nsDependentCSubstring& token = exposeTokens.nextToken();
for (const nsACString& token :
nsCCharSeparatedTokenizer(acExposedNames, ',').ToRange()) {
if (token.IsEmpty()) {
continue;
}

Просмотреть файл

@ -11,12 +11,6 @@
namespace mozilla::dom {
namespace {
bool TokenizerIgnoreNothing(char16_t /* aChar */) { return false; }
} // anonymous namespace
/* static */
bool FileSystemUtils::IsDescendantPath(const nsAString& aPath,
const nsAString& aDescendantPath) {
@ -47,11 +41,10 @@ bool FileSystemUtils::IsValidRelativeDOMPath(const nsAString& aPath,
constexpr auto kParentDir = u".."_ns;
// Split path and check each path component.
nsCharSeparatedTokenizerTemplate<TokenizerIgnoreNothing> tokenizer(
aPath, FILESYSTEM_DOM_PATH_SEPARATOR_CHAR);
while (tokenizer.hasMoreTokens()) {
nsDependentSubstring pathComponent = tokenizer.nextToken();
for (const nsAString& pathComponent :
nsCharSeparatedTokenizerTemplate<NS_TokenizerIgnoreNothing>{
aPath, FILESYSTEM_DOM_PATH_SEPARATOR_CHAR}
.ToRange()) {
// The path containing empty components, such as "foo//bar", is invalid.
// We don't allow paths, such as "../foo", "foo/./bar" and "foo/../bar",
// to walk up the directory.

Просмотреть файл

@ -65,8 +65,6 @@ using mozilla::ipc::IsOnBackgroundThread;
namespace {
bool TokenizerIgnoreNothing(char16_t /* aChar */) { return false; }
constexpr StructuredCloneFileBase::FileType ToStructuredCloneFileType(
const char16_t aTag) {
switch (aTag) {
@ -695,12 +693,10 @@ DeserializeStructuredCloneFiles(const FileManager& aFileManager,
const nsAString& aText) {
MOZ_ASSERT(!IsOnBackgroundThread());
nsCharSeparatedTokenizerTemplate<TokenizerIgnoreNothing> tokenizer(aText,
' ');
nsTArray<StructuredCloneFileParent> result;
while (tokenizer.hasMoreTokens()) {
const auto& token = tokenizer.nextToken();
for (const auto& token :
nsCharSeparatedTokenizerTemplate<NS_TokenizerIgnoreNothing>(aText, ' ')
.ToRange()) {
MOZ_ASSERT(!token.IsEmpty());
IDB_TRY_UNWRAP(auto structuredCloneFile,

Просмотреть файл

@ -323,10 +323,10 @@ nsresult IndexedDatabaseManager::Init() {
Preferences::GetLocalizedCString("intl.accept_languages", acceptLang);
// Split values on commas.
nsCCharSeparatedTokenizer langTokenizer(acceptLang, ',');
while (langTokenizer.hasMoreTokens()) {
nsAutoCString lang(langTokenizer.nextToken());
icu::Locale locale = icu::Locale::createCanonical(lang.get());
for (const auto& lang :
nsCCharSeparatedTokenizer(acceptLang, ',').ToRange()) {
icu::Locale locale =
icu::Locale::createCanonical(PromiseFlatCString(lang).get());
if (!locale.isBogus()) {
// icu::Locale::getBaseName is always ASCII as per BCP 47
mLocale.AssignASCII(locale.getBaseName());

Просмотреть файл

@ -32,12 +32,8 @@ using KeyPathTokenizer =
bool IsValidKeyPathString(const nsAString& aKeyPath) {
NS_ASSERTION(!aKeyPath.IsVoid(), "What?");
KeyPathTokenizer tokenizer(aKeyPath, '.');
while (tokenizer.hasMoreTokens()) {
const auto& token = tokenizer.nextToken();
if (!token.Length()) {
for (const auto& token : KeyPathTokenizer(aKeyPath, '.').ToRange()) {
if (token.IsEmpty()) {
return false;
}

Просмотреть файл

@ -57,9 +57,8 @@ static bool sInitializedSandboxingInfo = false;
// check comma delimited extensions
static bool ExtensionInList(const nsCString& aExtensionList,
const nsACString& aExtension) {
nsCCharSeparatedTokenizer extensions(aExtensionList, ',');
while (extensions.hasMoreTokens()) {
const nsACString& extension = extensions.nextToken();
for (const nsACString& extension :
nsCCharSeparatedTokenizer(aExtensionList, ',').ToRange()) {
if (extension.Equals(aExtension, nsCaseInsensitiveCStringComparator)) {
return true;
}

Просмотреть файл

@ -7769,17 +7769,12 @@ void ClientUsageArray::Serialize(nsACString& aText) const {
}
}
bool TokenizerIgnoreNothing(char16_t /* aChar */) { return false; }
nsresult ClientUsageArray::Deserialize(const nsACString& aText) {
nsresult rv;
nsCCharSeparatedTokenizerTemplate<TokenizerIgnoreNothing> tokenizer(aText,
' ');
while (tokenizer.hasMoreTokens()) {
const nsDependentCSubstring& token = tokenizer.nextToken();
for (const auto& token :
nsCCharSeparatedTokenizerTemplate<NS_TokenizerIgnoreNothing>(aText, ' ')
.ToRange()) {
if (NS_WARN_IF(token.Length() < 2)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -162,11 +162,8 @@ ReferrerPolicy ReferrerInfo::ReferrerPolicyFromHeaderString(
const nsAString& aContent) {
// Multiple headers could be concatenated into one comma-separated
// list of policies. Need to tokenize the multiple headers.
nsCharSeparatedTokenizer tokenizer(aContent, ',');
nsAutoString token;
ReferrerPolicyEnum referrerPolicy = ReferrerPolicy::_empty;
while (tokenizer.hasMoreTokens()) {
token = tokenizer.nextToken();
for (const auto& token : nsCharSeparatedTokenizer(aContent, ',').ToRange()) {
if (token.IsEmpty()) {
continue;
}

Просмотреть файл

@ -487,9 +487,8 @@ nsresult CSP_AppendCSPFromHeader(nsIContentSecurityPolicy* aCsp,
// concatenated into one comma-separated list of policies.
// See RFC2616 section 4.2 (last paragraph)
nsresult rv = NS_OK;
nsCharSeparatedTokenizer tokenizer(aHeaderValue, ',');
while (tokenizer.hasMoreTokens()) {
const nsAString& policy = tokenizer.nextToken();
for (const nsAString& policy :
nsCharSeparatedTokenizer(aHeaderValue, ',').ToRange()) {
rv = aCsp->AppendPolicy(policy, aReportOnly, false);
NS_ENSURE_SUCCESS(rv, rv);
{

Просмотреть файл

@ -357,9 +357,8 @@ bool nsMixedContentBlocker::IsPotentiallyTrustworthyOrigin(nsIURI* aURI) {
nsAutoCString allowlist;
GetSecureContextAllowList(allowlist);
nsCCharSeparatedTokenizer tokenizer(allowlist, ',');
while (tokenizer.hasMoreTokens()) {
const nsACString& allowedHost = tokenizer.nextToken();
for (const nsACString& allowedHost :
nsCCharSeparatedTokenizer(allowlist, ',').ToRange()) {
if (host.Equals(allowedHost)) {
return true;
}

Просмотреть файл

@ -432,12 +432,13 @@ const nsDependentSubstring SMILParserUtils::TrimWhitespace(
bool SMILParserUtils::ParseKeySplines(
const nsAString& aSpec, FallibleTArray<SMILKeySpline>& aKeySplines) {
nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace>
controlPointTokenizer(aSpec, ';');
while (controlPointTokenizer.hasMoreTokens()) {
for (const auto& controlPoint :
nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace>(aSpec,
';')
.ToRange()) {
nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace,
nsTokenizerFlags::SeparatorOptional>
tokenizer(controlPointTokenizer.nextToken(), ',');
tokenizer(controlPoint, ',');
double values[4];
for (auto& value : values) {

Просмотреть файл

@ -245,15 +245,15 @@ void SVGAnimatedTransformList::SMILAnimatedTransformList::ParseValue(
int32_t SVGAnimatedTransformList::SMILAnimatedTransformList::ParseParameterList(
const nsAString& aSpec, float* aVars, int32_t aNVars) {
nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace,
nsTokenizerFlags::SeparatorOptional>
tokenizer(aSpec, ',');
int numArgsFound = 0;
while (tokenizer.hasMoreTokens()) {
for (const auto& token :
nsCharSeparatedTokenizerTemplate<nsContentUtils::IsHTMLWhitespace,
nsTokenizerFlags::SeparatorOptional>(
aSpec, ',')
.ToRange()) {
float f;
if (!SVGContentUtils::ParseNumber(tokenizer.nextToken(), f)) {
if (!SVGContentUtils::ParseNumber(token, f)) {
return -1;
}
if (numArgsFound < aNVars) {

Просмотреть файл

@ -10,7 +10,6 @@
#include "mozilla/dom/SVGViewElement.h"
#include "mozilla/SVGOuterSVGFrame.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsContentUtils.h" // for nsCharSeparatedTokenizerTemplate
#include "SVGAnimatedTransformList.h"
namespace mozilla {
@ -25,8 +24,6 @@ static bool IsMatchingParameter(const nsAString& aString,
aString.CharAt(aParameterName.Length()) == '(';
}
inline bool IgnoreWhitespace(char16_t aChar) { return false; }
static SVGViewElement* GetViewElement(Document* aDocument,
const nsAString& aId) {
Element* element = aDocument->GetElementById(aId);
@ -130,7 +127,7 @@ bool SVGFragmentIdentifier::ProcessSVGViewSpec(const nsAString& aViewSpec,
// Each token is a SVGViewAttribute
int32_t bracketPos = aViewSpec.FindChar('(');
uint32_t lengthOfViewSpec = aViewSpec.Length() - bracketPos - 2;
nsCharSeparatedTokenizerTemplate<IgnoreWhitespace> tokenizer(
nsCharSeparatedTokenizerTemplate<NS_TokenizerIgnoreNothing> tokenizer(
Substring(aViewSpec, bracketPos + 1, lengthOfViewSpec), ';');
if (!tokenizer.hasMoreTokens()) {

Просмотреть файл

@ -68,10 +68,9 @@ int32_t SVGTests::GetBestLanguagePreferenceRank(
int32_t lowestRank = -1;
for (uint32_t i = 0; i < mStringListAttributes[LANGUAGE].Length(); i++) {
nsCharSeparatedTokenizer languageTokenizer(aAcceptLangs, ',');
int32_t index = 0;
while (languageTokenizer.hasMoreTokens()) {
const nsAString& languageToken = languageTokenizer.nextToken();
for (const nsAString& languageToken :
nsCharSeparatedTokenizer(aAcceptLangs, ',').ToRange()) {
bool exactMatch = languageToken.Equals(mStringListAttributes[LANGUAGE][i],
nsCaseInsensitiveStringComparator);
bool prefixOnlyMatch =

Просмотреть файл

@ -1085,10 +1085,9 @@ bool XMLHttpRequestMainThread::IsSafeHeader(
// list of method names.
Unused << aHttpChannel->GetResponseHeader("Access-Control-Expose-Headers"_ns,
headerVal);
nsCCharSeparatedTokenizer exposeTokens(headerVal, ',');
bool isSafe = false;
while (exposeTokens.hasMoreTokens()) {
const nsDependentCSubstring& token = exposeTokens.nextToken();
for (const nsACString& token :
nsCCharSeparatedTokenizer(headerVal, ',').ToRange()) {
if (token.IsEmpty()) {
continue;
}

Просмотреть файл

@ -1497,9 +1497,8 @@ void gfxDWriteFontList::InitSharedFontListForPlatform() {
"gfx.font_rendering.cleartype_params.force_gdi_classic_for_families",
classicFamilies);
if (NS_SUCCEEDED(rv)) {
nsCCharSeparatedTokenizer tokenizer(classicFamilies, ',');
while (tokenizer.hasMoreTokens()) {
nsAutoCString name(tokenizer.nextToken());
for (auto name :
nsCCharSeparatedTokenizer(classicFamilies, ',').ToRange()) {
BuildKeyNameFromFontName(name);
forceClassicFams.AppendElement(name);
}

Просмотреть файл

@ -320,10 +320,8 @@ bool nsMediaFragmentURIParser::ParseXYWH(nsDependentSubstring aString) {
void nsMediaFragmentURIParser::Parse(nsACString& aRef) {
// Create an array of possibly-invalid media fragments.
nsTArray<std::pair<nsCString, nsCString> > fragments;
nsCCharSeparatedTokenizer tokenizer(aRef, '&');
while (tokenizer.hasMoreTokens()) {
const nsACString& nv = tokenizer.nextToken();
for (const nsACString& nv : nsCCharSeparatedTokenizer(aRef, '&').ToRange()) {
int32_t index = nv.FindChar('=');
if (index >= 0) {
nsAutoCString name;

Просмотреть файл

@ -396,10 +396,9 @@ nsresult TRR::DohDecodeQuery(const nsCString& query, nsCString& host,
LOG(("TRR::DohDecodeQuery %s!\n", query.get()));
// extract "dns=" from the query string
nsCCharSeparatedTokenizer tokenizer(query, '&');
nsAutoCString data;
while (tokenizer.hasMoreTokens()) {
const nsACString& token = tokenizer.nextToken();
for (const nsACString& token :
nsCCharSeparatedTokenizer(query, '&').ToRange()) {
nsDependentCSubstring dns = Substring(token, 0, 4);
nsAutoCString check(dns);
if (check.Equals("dns=")) {

Просмотреть файл

@ -360,11 +360,12 @@ nsresult TRRService::ReadPrefs(const char* name) {
return;
}
nsCCharSeparatedTokenizerTemplate<NS_IsAsciiWhitespace,
nsTokenizerFlags::SeparatorOptional>
tokenizer(excludedDomains, ',');
while (tokenizer.hasMoreTokens()) {
nsAutoCString token(tokenizer.nextToken());
for (const nsACString& tokenSubstring :
nsCCharSeparatedTokenizerTemplate<
NS_IsAsciiWhitespace, nsTokenizerFlags::SeparatorOptional>(
excludedDomains, ',')
.ToRange()) {
nsCString token{tokenSubstring};
LOG(("TRRService::ReadPrefs %s host:[%s]\n", aPrefName, token.get()));
mExcludedDomains.PutEntry(token);
}

Просмотреть файл

@ -740,13 +740,12 @@ nsresult nsDNSService::ReadPrefs(const char* name) {
Preferences::GetCString(kPrefDnsLocalDomains, localDomains);
MutexAutoLock lock(mLock);
mLocalDomains.Clear();
if (!localDomains.IsEmpty()) {
nsCCharSeparatedTokenizerTemplate<NS_IsAsciiWhitespace,
nsTokenizerFlags::SeparatorOptional>
tokenizer(localDomains, ',');
while (tokenizer.hasMoreTokens()) {
mLocalDomains.PutEntry(tokenizer.nextToken());
}
for (const auto& token :
nsCCharSeparatedTokenizerTemplate<NS_IsAsciiWhitespace,
nsTokenizerFlags::SeparatorOptional>(
localDomains, ',')
.ToRange()) {
mLocalDomains.PutEntry(token);
}
}
if (!name || !strcmp(name, kPrefDnsForceResolve)) {

Просмотреть файл

@ -489,9 +489,8 @@ nsresult Http2Decompressor::DecodeInteger(uint32_t prefixLen, uint32_t& accum) {
}
static bool HasConnectionBasedAuth(const nsACString& headerValue) {
nsCCharSeparatedTokenizer t(headerValue, '\n');
while (t.hasMoreTokens()) {
const nsDependentCSubstring& authMethod = t.nextToken();
for (const nsACString& authMethod :
nsCCharSeparatedTokenizer(headerValue, '\n').ToRange()) {
if (authMethod.LowerCaseEqualsLiteral("ntlm")) {
return true;
}

Просмотреть файл

@ -1148,9 +1148,8 @@ void nsCORSPreflightListener::AddResultToCache(nsIRequest* aRequest) {
Unused << http->GetResponseHeader("Access-Control-Allow-Methods"_ns,
headerVal);
nsCCharSeparatedTokenizer methods(headerVal, ',');
while (methods.hasMoreTokens()) {
const nsDependentCSubstring& method = methods.nextToken();
for (const nsACString& method :
nsCCharSeparatedTokenizer(headerVal, ',').ToRange()) {
if (method.IsEmpty()) {
continue;
}
@ -1177,9 +1176,8 @@ void nsCORSPreflightListener::AddResultToCache(nsIRequest* aRequest) {
Unused << http->GetResponseHeader("Access-Control-Allow-Headers"_ns,
headerVal);
nsCCharSeparatedTokenizer headers(headerVal, ',');
while (headers.hasMoreTokens()) {
const nsDependentCSubstring& header = headers.nextToken();
for (const nsACString& header :
nsCCharSeparatedTokenizer(headerVal, ',').ToRange()) {
if (header.IsEmpty()) {
continue;
}
@ -1292,9 +1290,8 @@ nsresult nsCORSPreflightListener::CheckPreflightRequestApproved(
bool foundMethod = mPreflightMethod.EqualsLiteral("GET") ||
mPreflightMethod.EqualsLiteral("HEAD") ||
mPreflightMethod.EqualsLiteral("POST");
nsCCharSeparatedTokenizer methodTokens(headerVal, ',');
while (methodTokens.hasMoreTokens()) {
const nsDependentCSubstring& method = methodTokens.nextToken();
for (const nsACString& method :
nsCCharSeparatedTokenizer(headerVal, ',').ToRange()) {
if (method.IsEmpty()) {
continue;
}
@ -1324,10 +1321,9 @@ nsresult nsCORSPreflightListener::CheckPreflightRequestApproved(
Unused << http->GetResponseHeader("Access-Control-Allow-Headers"_ns,
headerVal);
nsTArray<nsCString> headers;
nsCCharSeparatedTokenizer headerTokens(headerVal, ',');
bool allowAllHeaders = false;
while (headerTokens.hasMoreTokens()) {
const nsDependentCSubstring& header = headerTokens.nextToken();
for (const nsACString& header :
nsCCharSeparatedTokenizer(headerVal, ',').ToRange()) {
if (header.IsEmpty()) {
continue;
}

Просмотреть файл

@ -2047,9 +2047,9 @@ void nsHttpHandler::PrefsChanged(const char* pref) {
rv = Preferences::GetCString(HTTP_PREF("http3.alt-svc-mapping-for-testing"),
altSvcMappings);
if (NS_SUCCEEDED(rv)) {
nsCCharSeparatedTokenizer tokenizer(altSvcMappings, ',');
while (tokenizer.hasMoreTokens()) {
nsAutoCString token(tokenizer.nextToken());
for (const nsACString& tokenSubstring :
nsCCharSeparatedTokenizer(altSvcMappings, ',').ToRange()) {
nsAutoCString token{tokenSubstring};
int32_t index = token.Find(";");
if (index != kNotFound) {
auto* map = new nsCString(Substring(token, index + 1));

Просмотреть файл

@ -2637,16 +2637,16 @@ void ProcessServerWebSocketExtensions(const nsACString& aExtensions,
}
}
nsCCharSeparatedTokenizer extList(aExtensions, ',');
while (extList.hasMoreTokens()) {
for (const auto& ext :
nsCCharSeparatedTokenizer(aExtensions, ',').ToRange()) {
bool clientNoContextTakeover;
bool serverNoContextTakeover;
int32_t clientMaxWindowBits;
int32_t serverMaxWindowBits;
nsresult rv = ParseWebSocketExtension(
extList.nextToken(), eParseServerSide, clientNoContextTakeover,
serverNoContextTakeover, clientMaxWindowBits, serverMaxWindowBits);
ext, eParseServerSide, clientNoContextTakeover, serverNoContextTakeover,
clientMaxWindowBits, serverMaxWindowBits);
if (NS_FAILED(rv)) {
// Ignore extensions that we can't parse
continue;

Просмотреть файл

@ -260,9 +260,8 @@ bool nsChannelClassifier::IsHostnameEntitylisted(
}
ToLowerCase(host);
nsCCharSeparatedTokenizer tokenizer(aEntitylisted, ',');
while (tokenizer.hasMoreTokens()) {
const nsACString& token = tokenizer.nextToken();
for (const nsACString& token :
nsCCharSeparatedTokenizer(aEntitylisted, ',').ToRange()) {
if (token.Equals(host)) {
UC_LOG(
("nsChannelClassifier::StartInternal - skipping %s (entitylisted) "

Просмотреть файл

@ -1598,14 +1598,7 @@ void nsSSLIOLayerHelpers::setInsecureFallbackSites(const nsCString& str) {
mInsecureFallbackSites.Clear();
if (str.IsEmpty()) {
return;
}
nsCCharSeparatedTokenizer toker(str, ',');
while (toker.hasMoreTokens()) {
const nsACString& host = toker.nextToken();
for (const nsACString& host : nsCCharSeparatedTokenizer(str, ',').ToRange()) {
if (!host.IsEmpty()) {
mInsecureFallbackSites.PutEntry(host);
}
@ -1639,10 +1632,9 @@ FallbackPrefRemover::Run() {
MOZ_ASSERT(NS_IsMainThread());
nsAutoCString oldValue;
Preferences::GetCString("security.tls.insecure_fallback_hosts", oldValue);
nsCCharSeparatedTokenizer toker(oldValue, ',');
nsCString newValue;
while (toker.hasMoreTokens()) {
const nsACString& host = toker.nextToken();
for (const nsACString& host :
nsCCharSeparatedTokenizer(oldValue, ',').ToRange()) {
if (host.Equals(mHost)) {
continue;
}

Просмотреть файл

@ -34,13 +34,7 @@ nsresult URLDecorationStripper::StripTrackingIdentifiers(nsIURI* aURI,
int32_t queryBegins = path.FindChar('?');
// Only positive values are valid since the path must begin with a '/'.
if (queryBegins > 0) {
typedef nsCharSeparatedTokenizerTemplate<NS_TokenizerIgnoreNothing>
Tokenizer;
Tokenizer tokenizer(tokenList, ' ');
nsAutoString token;
while (tokenizer.hasMoreTokens()) {
token = tokenizer.nextToken();
for (const nsAString& token : tokenList.Split(' ')) {
if (token.IsEmpty()) {
continue;
}

Просмотреть файл

@ -229,9 +229,9 @@ uint32_t ClearSiteData::ParseHeader(nsIHttpChannel* aChannel,
uint32_t flags = 0;
nsCCharSeparatedTokenizer token(headerValue, ',');
while (token.hasMoreTokens()) {
auto value = token.nextToken();
for (auto value : nsCCharSeparatedTokenizer(headerValue, ',').ToRange()) {
// XXX This seems unnecessary, since the tokenizer already strips whitespace
// around tokens.
value.StripTaggedASCII(mozilla::ASCIIMask::MaskWhitespace());
if (value.EqualsLiteral("\"cache\"")) {

Просмотреть файл

@ -231,9 +231,8 @@ void SessionStoreUtils::RestoreDocShellCapabilities(
aDocShell->SetAllowContentRetargeting(true);
aDocShell->SetAllowContentRetargetingOnChildren(true);
nsCCharSeparatedTokenizer tokenizer(aDisallowCapabilities, ',');
while (tokenizer.hasMoreTokens()) {
const nsACString& token = tokenizer.nextToken();
for (const nsACString& token :
nsCCharSeparatedTokenizer(aDisallowCapabilities, ',').ToRange()) {
if (token.EqualsLiteral("Plugins")) {
aDocShell->SetAllowPlugins(false);
} else if (token.EqualsLiteral("Javascript")) {