Blame SOURCES/CVE-2021-28957.patch

4055cc
diff --git a/src/lxml/html/defs.py b/src/lxml/html/defs.py
4055cc
index caf6b21..ea3c016 100644
4055cc
--- a/src/lxml/html/defs.py
4055cc
+++ b/src/lxml/html/defs.py
4055cc
@@ -21,6 +21,8 @@ link_attrs = frozenset([
4055cc
     'usemap',
4055cc
     # Not standard:
4055cc
     'dynsrc', 'lowsrc',
4055cc
+    # HTML5 formaction
4055cc
+    'formaction'
4055cc
     ])
4055cc
 
4055cc
 # Not in the HTML 4 spec:
4055cc
diff --git a/src/lxml/html/tests/test_clean.py b/src/lxml/html/tests/test_clean.py
4055cc
index 451eec2..e40cdad 100644
4055cc
--- a/src/lxml/html/tests/test_clean.py
4055cc
+++ b/src/lxml/html/tests/test_clean.py
4055cc
@@ -89,6 +89,21 @@ class CleanerTest(unittest.TestCase):
4055cc
             b'<math><style>/* deleted */</style></math>',
4055cc
             lxml.html.tostring(clean_html(s)))
4055cc
 
4055cc
+    def test_formaction_attribute_in_button_input(self):
4055cc
+        # The formaction attribute overrides the form's action and should be
4055cc
+        # treated as a malicious link attribute
4055cc
+        html = ('<form id="test"><input type="submit" formaction="javascript:alert(1)"></form>'
4055cc
+        '<button form="test" formaction="javascript:alert(1)">X</button>')
4055cc
+        expected = ('
<form id="test"><input type="submit" formaction=""></form>'
4055cc
+        '<button form="test" formaction="">X</button>')
4055cc
+        cleaner = Cleaner(
4055cc
+            forms=False,
4055cc
+            safe_attrs_only=False,
4055cc
+        )
4055cc
+        self.assertEqual(
4055cc
+            expected,
4055cc
+            cleaner.clean_html(html))
4055cc
+
4055cc
 
4055cc
 def test_suite():
4055cc
     suite = unittest.TestSuite()