Bug 1779184 - Remove lowercasing of elements/attributes. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D154221
This commit is contained in:
Tom Schuster 2022-08-12 10:33:26 +00:00
Родитель 1173a0bda6
Коммит 0c4ace9581
2 изменённых файлов: 7 добавлений и 41 удалений

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

@ -2424,9 +2424,7 @@ void nsTreeSanitizer::WithWebSanitizerOptions(
const Sequence<nsString>& allowedElements = aOptions.mAllowElements.Value();
mAllowElements = MakeUnique<DynamicAtomsTable>(allowedElements.Length());
for (const nsString& elem : allowedElements) {
nsAutoString lowercaseElem;
nsContentUtils::ASCIIToLower(elem, lowercaseElem);
RefPtr<nsAtom> elAsAtom = NS_AtomizeMainThread(lowercaseElem);
RefPtr<nsAtom> elAsAtom = NS_AtomizeMainThread(elem);
mAllowElements->Insert(elAsAtom);
}
}
@ -2435,9 +2433,7 @@ void nsTreeSanitizer::WithWebSanitizerOptions(
const Sequence<nsString>& blockedElements = aOptions.mBlockElements.Value();
mBlockElements = MakeUnique<DynamicAtomsTable>(blockedElements.Length());
for (const nsString& elem : blockedElements) {
nsAutoString lowercaseElem;
nsContentUtils::ASCIIToLower(elem, lowercaseElem);
RefPtr<nsAtom> elAsAtom = NS_AtomizeMainThread(lowercaseElem);
RefPtr<nsAtom> elAsAtom = NS_AtomizeMainThread(elem);
mBlockElements->Insert(elAsAtom);
}
}
@ -2446,9 +2442,7 @@ void nsTreeSanitizer::WithWebSanitizerOptions(
const Sequence<nsString>& dropElements = aOptions.mDropElements.Value();
mDropElements = MakeUnique<DynamicAtomsTable>(dropElements.Length());
for (const nsString& elem : dropElements) {
nsAutoString lowercaseElem;
nsContentUtils::ASCIIToLower(elem, lowercaseElem);
RefPtr<nsAtom> elAsAtom = NS_AtomizeMainThread(lowercaseElem);
RefPtr<nsAtom> elAsAtom = NS_AtomizeMainThread(elem);
mDropElements->Insert(elAsAtom);
}
}
@ -2462,14 +2456,10 @@ void nsTreeSanitizer::WithWebSanitizerOptions(
UniquePtr<DynamicAtomsTable> elems =
MakeUnique<DynamicAtomsTable>(allowedAttributes.Entries().Length());
for (const auto& elem : entries.mValue) {
nsAutoString lowercaseElem;
nsContentUtils::ASCIIToLower(elem, lowercaseElem);
RefPtr<nsAtom> elAsAtom = NS_Atomize(lowercaseElem);
RefPtr<nsAtom> elAsAtom = NS_AtomizeMainThread(elem);
elems->Insert(elAsAtom);
}
nsAutoString attrName;
nsContentUtils::ASCIIToLower(entries.mKey, attrName);
RefPtr<nsAtom> attrAtom = NS_Atomize(attrName);
RefPtr<nsAtom> attrAtom = NS_AtomizeMainThread(entries.mKey);
mAllowedAttributes->InsertOrUpdate(attrAtom, std::move(elems));
}
}
@ -2483,17 +2473,11 @@ void nsTreeSanitizer::WithWebSanitizerOptions(
UniquePtr<DynamicAtomsTable> elems =
MakeUnique<DynamicAtomsTable>(droppedAttributes.Entries().Length());
for (const auto& elem : entries.mValue) {
nsAutoString lowercaseElem;
nsContentUtils::ASCIIToLower(elem, lowercaseElem);
RefPtr<nsAtom> elAsAtom = NS_Atomize(lowercaseElem);
RefPtr<nsAtom> elAsAtom = NS_AtomizeMainThread(elem);
elems->Insert(elAsAtom);
}
nsAutoString attrName;
nsContentUtils::ASCIIToLower(entries.mKey, attrName);
RefPtr<nsAtom> attrAtom = NS_Atomize(attrName);
RefPtr<nsAtom> attrAtom = NS_AtomizeMainThread(entries.mKey);
mDroppedAttributes->InsertOrUpdate(attrAtom, std::move(elems));
}
}
// TODO(freddy) Add handling of other keys in SanitizerConfig
}

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

@ -33,15 +33,6 @@
[SanitizerAPI with config: HTMLButtonElement with javascript formaction start with space, sanitize from document function for <body>]
expected: FAIL
[SanitizerAPI with config: dropElements list ["I", "DL"\]}, sanitize from document function for <body>]
expected: FAIL
[SanitizerAPI with config: dropAttributes list {"ID": ["*"\]} with id attribute, sanitize from document function for <body>]
expected: FAIL
[SanitizerAPI with config: dropAttributes list {"ID": ["*"\]} with ID attribute, sanitize from document function for <body>]
expected: FAIL
[SanitizerAPI with config: allowAttributes unknown attributes and with allowUnknownMarkup, sanitize from document function for <body>]
expected: FAIL
@ -78,14 +69,5 @@
[SanitizerAPI with config: HTMLButtonElement with javascript formaction start with space, sanitize from document fragment function for <template>]
expected: FAIL
[SanitizerAPI with config: dropElements list ["I", "DL"\]}, sanitize from document fragment function for <template>]
expected: FAIL
[SanitizerAPI with config: dropAttributes list {"ID": ["*"\]} with id attribute, sanitize from document fragment function for <template>]
expected: FAIL
[SanitizerAPI with config: dropAttributes list {"ID": ["*"\]} with ID attribute, sanitize from document fragment function for <template>]
expected: FAIL
[SanitizerAPI with config: allowAttributes unknown attributes and with allowUnknownMarkup, sanitize from document fragment function for <template>]
expected: FAIL