From fa45f2b43f5907e265e4bdcfa0d0b869c1c39c0f Mon Sep 17 00:00:00 2001
From: Michael Webster <miketwebster@gmail.com>
Date: Tue, 14 Feb 2023 13:47:30 -0500
Subject: [PATCH] Revert "third_party/mako: Update Mako to version 1.2.4"

This reverts commit 048cc41b1b5c943ac11cdf3438d518638f8398e6.
---
 third_party/mako/README.chromium         |  8 +++----
 third_party/mako/mako/mako/__init__.py   |  2 +-
 third_party/mako/mako/mako/codegen.py    |  9 ++------
 third_party/mako/mako/mako/lexer.py      | 14 +++++-------
 third_party/mako/mako/setup.cfg          |  2 +-
 third_party/mako/mako/test/test_lexer.py | 27 ++++--------------------
 third_party/mako/mako/test/test_loop.py  | 17 +++------------
 7 files changed, 20 insertions(+), 59 deletions(-)

diff --git a/third_party/mako/README.chromium b/third_party/mako/README.chromium
index 7ad9fab3c855..8a76367a000c 100644
--- a/third_party/mako/README.chromium
+++ b/third_party/mako/README.chromium
@@ -1,8 +1,8 @@
 Name: Mako Templates for Python
 Short Name: python-mako
 URL: https://www.makotemplates.org
-Version: 1.2.4
-Date: November 15, 2022
+Version: 1.2.1
+Date: July 1, 2022
 License: MIT
 License File: NOT_SHIPPED
 Security Critical: no
@@ -10,8 +10,8 @@ Security Critical: no
 Description:
 Template engine in Python, used for code generation in Blink.
 
-Source: https://files.pythonhosted.org/packages/05/5f/2ba6e026d33a0e6ddc1dddf9958677f76f5f80c236bd65309d280b166d3e/Mako-1.2.4.tar.gz
-SHA-256: d60a3903dc3bb01a18ad6a89cdbe2e4eadc69c0bc8ef1e3773ba53d44c3f7a34
+Source: https://files.pythonhosted.org/packages/ad/dd/34201dae727bb183ca14fd8417e61f936fa068d6f503991f09ee3cac6697/Mako-1.2.1.tar.gz
+SHA-256: f054a5ff4743492f1aa9ecc47172cb33b42b9d993cffcc146c9de17e717b0307
 
 Local Modifications:
 * add DIR_METADATA, OWNERS, README.chromium, and .gitattributes files in this directory.
diff --git a/third_party/mako/mako/mako/__init__.py b/third_party/mako/mako/mako/__init__.py
index d73392190cdb..f105e78cd168 100644
--- a/third_party/mako/mako/mako/__init__.py
+++ b/third_party/mako/mako/mako/__init__.py
@@ -5,4 +5,4 @@
 # the MIT License: http://www.opensource.org/licenses/mit-license.php
 
 
-__version__ = "1.2.4"
+__version__ = "1.2.1"
diff --git a/third_party/mako/mako/mako/codegen.py b/third_party/mako/mako/mako/codegen.py
index d1d2c20a0216..a9dbcb6799fb 100644
--- a/third_party/mako/mako/mako/codegen.py
+++ b/third_party/mako/mako/mako/codegen.py
@@ -1251,13 +1251,8 @@ class _Identifiers:
 
 
 _FOR_LOOP = re.compile(
-    r"^for\s+((?:\(?)\s*"
-    r"(?:\(?)\s*[A-Za-z_][A-Za-z_0-9]*"
-    r"(?:\s*,\s*(?:[A-Za-z_][A-Za-z_0-9]*),??)*\s*(?:\)?)"
-    r"(?:\s*,\s*(?:"
-    r"(?:\(?)\s*[A-Za-z_][A-Za-z_0-9]*"
-    r"(?:\s*,\s*(?:[A-Za-z_][A-Za-z_0-9]*),??)*\s*(?:\)?)"
-    r"),??)*\s*(?:\)?))\s+in\s+(.*):"
+    r"^for\s+((?:\(?)\s*[A-Za-z_][A-Za-z_0-9]*"
+    r"(?:\s*,\s*(?:[A-Za-z_][A-Za-z0-9_]*),??)*\s*(?:\)?))\s+in\s+(.*):"
 )
 
 
diff --git a/third_party/mako/mako/mako/lexer.py b/third_party/mako/mako/mako/lexer.py
index 75182f852dba..bfcf28691a5c 100644
--- a/third_party/mako/mako/mako/lexer.py
+++ b/third_party/mako/mako/mako/lexer.py
@@ -272,24 +272,20 @@ class Lexer:
         return self.template
 
     def match_tag_start(self):
-        reg = r"""
+        match = self.match(
+            r"""
             \<%     # opening tag
 
             ([\w\.\:]+)   # keyword
 
-            ((?:\s+\w+|\s*=\s*|"[^"]*?"|'[^']*?'|\s*,\s*)*)  # attrname, = \
+            ((?:\s+\w+|\s*=\s*|".*?"|'.*?')*)  # attrname, = \
                                                #        sign, string expression
-                                               # comma is for backwards compat
-                                               # identified in #366
 
             \s*     # more whitespace
 
             (/)?>   # closing
 
-        """
-
-        match = self.match(
-            reg,
+            """,
             re.I | re.S | re.X,
         )
 
@@ -322,7 +318,7 @@ class Lexer:
         return True
 
     def match_tag_end(self):
-        match = self.match(r"\</%[\t ]*([^\t ]+?)[\t ]*>")
+        match = self.match(r"\</%[\t ]*(.+?)[\t ]*>")
         if match:
             if not len(self.tag):
                 raise exceptions.SyntaxException(
diff --git a/third_party/mako/mako/setup.cfg b/third_party/mako/mako/setup.cfg
index 37ca9e9e7095..bcfefa1b50c7 100644
--- a/third_party/mako/mako/setup.cfg
+++ b/third_party/mako/mako/setup.cfg
@@ -71,7 +71,7 @@ tag_date = 0
 [tool:pytest]
 addopts = --tb native -v -r fxX -p warnings
 python_files = test/*test_*.py
-python_classes = *Test Test*
+python_classes = *Test
 filterwarnings = 
 	error::DeprecationWarning:test
 	error::DeprecationWarning:mako
diff --git a/third_party/mako/mako/test/test_lexer.py b/third_party/mako/mako/test/test_lexer.py
index f4983a3a9ab0..255c128f8de4 100644
--- a/third_party/mako/mako/test/test_lexer.py
+++ b/third_party/mako/mako/test/test_lexer.py
@@ -1,7 +1,5 @@
 import re
 
-import pytest
-
 from mako import compat
 from mako import exceptions
 from mako import parsetree
@@ -148,16 +146,6 @@ class LexerTest(TemplateTest):
         """
         assert_raises(exceptions.CompileException, Lexer(template).parse)
 
-    def test_closing_tag_many_spaces(self):
-        """test #367"""
-        template = '<%def name="foo()"> this is a def. </%' + " " * 10000
-        assert_raises(exceptions.SyntaxException, Lexer(template).parse)
-
-    def test_opening_tag_many_quotes(self):
-        """test #366"""
-        template = "<%0" + '"' * 3000
-        assert_raises(exceptions.SyntaxException, Lexer(template).parse)
-
     def test_unmatched_tag(self):
         template = """
         <%namespace name="bar">
@@ -444,16 +432,9 @@ class LexerTest(TemplateTest):
             ),
         )
 
-    @pytest.mark.parametrize("comma,numchars", [(",", 48), ("", 47)])
-    def test_pagetag(self, comma, numchars):
-        # note that the comma here looks like:
-        # <%page cached="True", args="a, b"/>
-        # that's what this test has looked like for decades, however, the
-        # comma there is not actually the right syntax.  When issue #366
-        # was fixed, the reg was altered to accommodate for this comma to allow
-        # backwards compat
-        template = f"""
-            <%page cached="True"{comma} args="a, b"/>
+    def test_pagetag(self):
+        template = """
+            <%page cached="True", args="a, b"/>
 
             some template
         """
@@ -472,7 +453,7 @@ class LexerTest(TemplateTest):
 
             some template
         """,
-                        (2, numchars),
+                        (2, 48),
                     ),
                 ],
             ),
diff --git a/third_party/mako/mako/test/test_loop.py b/third_party/mako/mako/test/test_loop.py
index 2c1100083610..19d40b542d36 100644
--- a/third_party/mako/mako/test/test_loop.py
+++ b/third_party/mako/mako/test/test_loop.py
@@ -1,5 +1,4 @@
 import re
-import unittest
 
 from mako import exceptions
 from mako.codegen import _FOR_LOOP
@@ -12,7 +11,7 @@ from mako.testing.fixtures import TemplateTest
 from mako.testing.helpers import flatten_result
 
 
-class TestLoop(unittest.TestCase):
+class TestLoop:
     def test__FOR_LOOP(self):
         for statement, target_list, expression_list in (
             ("for x in y:", "x", "y"),
@@ -31,16 +30,6 @@ class TestLoop(unittest.TestCase):
                 "x",
                 "[y+1 for y in [1, 2, 3]]",
             ),
-            (
-                "for ((key1, val1), (key2, val2)) in pairwise(dict.items()):",
-                "((key1, val1), (key2, val2))",
-                "pairwise(dict.items())",
-            ),
-            (
-                "for (key1, val1), (key2, val2) in pairwise(dict.items()):",
-                "(key1, val1), (key2, val2)",
-                "pairwise(dict.items())",
-            ),
         ):
             match = _FOR_LOOP.match(statement)
             assert match and match.groups() == (target_list, expression_list)
@@ -147,7 +136,7 @@ ${x} ${loop.index} <- outer loop
         )
 
 
-class TestLoopStack(unittest.TestCase):
+class TestLoopStack:
     def setUp(self):
         self.stack = LoopStack()
         self.bottom = "spam"
@@ -190,7 +179,7 @@ class TestLoopStack(unittest.TestCase):
         assert before == (after + 1), "Exiting a context pops the stack"
 
 
-class TestLoopContext(unittest.TestCase):
+class TestLoopContext:
     def setUp(self):
         self.iterable = [1, 2, 3]
         self.ctx = LoopContext(self.iterable)
-- 
2.34.1

