加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2020-26956-1.patch 2.08 KB
一键复制 编辑 原始数据 按行查看 历史
wangxiao65 提交于 2021-01-07 15:15 . fix cves
# HG changeset patch
# User Henri Sivonen <hsivonen@hsivonen.fi>
# Date 1603457329 0
# Fri Oct 23 12:48:49 2020 +0000
# Node ID 3476387362fb15c82f133f390afef719ad36de0a
# Parent fd45fcfd6261e9ed6cf83e54ad8286717f1b4762
Bug 1666300 part 1 - Remove attributes from descendants when setting sanitized style. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D93215
diff -r fd45fcfd6261 -r 3476387362fb dom/base/nsTreeSanitizer.cpp
--- a/dom/base/nsTreeSanitizer.cpp Fri Oct 23 13:04:19 2020 +0000
+++ b/dom/base/nsTreeSanitizer.cpp Fri Oct 23 12:48:49 2020 +0000
@@ -1341,6 +1341,7 @@
nsAutoString sanitizedStyle;
SanitizeStyleSheet(styleText, sanitizedStyle, aRoot->OwnerDoc(),
node->GetBaseURI());
+ RemoveAllAttributesFromDescendants(elt);
nsContentUtils::SetNodeTextContent(node, sanitizedStyle, true);
if (!mOnlyConditionalCSS) {
@@ -1427,6 +1428,18 @@
}
}
+void nsTreeSanitizer::RemoveAllAttributesFromDescendants(
+ mozilla::dom::Element* aElement) {
+ nsIContent* node = aElement->GetFirstChild();
+ while (node) {
+ if (node->IsElement()) {
+ mozilla::dom::Element* elt = node->AsElement();
+ RemoveAllAttributes(elt);
+ }
+ node = node->GetNextNode(aElement);
+ }
+}
+
void nsTreeSanitizer::LogMessage(const char* aMessage, Document* aDoc,
Element* aElement, nsAtom* aAttr) {
if (mLogRemovals) {
diff -r fd45fcfd6261 -r 3476387362fb dom/base/nsTreeSanitizer.h
--- a/dom/base/nsTreeSanitizer.h Fri Oct 23 13:04:19 2020 +0000
+++ b/dom/base/nsTreeSanitizer.h Fri Oct 23 12:48:49 2020 +0000
@@ -200,6 +200,12 @@
void RemoveAllAttributes(mozilla::dom::Element* aElement);
/**
+ * Removes all attributes from the descendants of an element but not from
+ * the element itself.
+ */
+ void RemoveAllAttributesFromDescendants(mozilla::dom::Element* aElement);
+
+ /**
* Log a Console Service message to indicate we removed something.
* If you pass an element and/or attribute, their information will
* be appended to the message.
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化