Debian Codegraph @

debian/patches/0004-test-Fix-regex-syntax-errors.patch

raw
1 From: Keith Packard <[email protected]>
2 Date: Sun, 5 Jan 2025 16:51:03 -0800
3 Subject: test: Fix regex syntax errors
4
5 The regular expressions in normalize.py and pathological_tests.py are
6 missing a lot of backslashes -- you need two in the source file to get
7 one in the string.
8
9 Signed-off-by: Keith Packard <[email protected]>
10 ---
11 test/normalize.py | 4 ++--
12 test/pathological_tests.py | 20 ++++++++++----------
13 2 files changed, 12 insertions(+), 12 deletions(-)
14
15 diff --git a/test/normalize.py b/test/normalize.py
16 index b7fd9b2..ec4979c 100644
17 --- a/test/normalize.py
18 +++ b/test/normalize.py
19 @@ -18,7 +18,7 @@ import re
20 # Normalization code, adapted from
21 # https://github.com/karlcow/markdown-testsuite/
22 significant_attrs = ["alt", "href", "src", "title"]
23 -whitespace_re = re.compile('\s+')
24 +whitespace_re = re.compile('\\s+')
25 class MyHTMLParser(HTMLParser):
26 def __init__(self):
27 HTMLParser.__init__(self)
28 @@ -176,7 +176,7 @@ def normalize_html(html):
29 '\u2200&amp;&gt;&lt;&quot;'
30
31 """
32 - html_chunk_re = re.compile("(\<!\[CDATA\[.*?\]\]\>|\<[^>]*\>|[^<]+)")
33 + html_chunk_re = re.compile("(\\<!\\[CDATA\\[.*?\\]\\]\\>|\\<[^>]*\\>|[^<]+)")
34 try:
35 parser = MyHTMLParser()
36 # We work around HTMLParser's limitations parsing CDATA
37 diff --git a/test/pathological_tests.py b/test/pathological_tests.py
38 index f556a1d..80b5261 100644
39 --- a/test/pathological_tests.py
40 +++ b/test/pathological_tests.py
41 @@ -30,7 +30,7 @@ def hash_collisions():
42
43 document = ''.join("[%s]: /url\n\n[%s]\n\n" % (key, bad_key) for key in collisions)
44
45 - return document, re.compile("(<p>\[%s\]</p>\n){%d}" % (bad_key, COUNT-1))
46 + return document, re.compile("(<p>\\[%s\\]</p>\n){%d}" % (bad_key, COUNT-1))
47
48 allowed_failures = {"many references": True}
49
50 @@ -48,10 +48,10 @@ pathological = {
51 re.compile("(_a ){64999}_a")),
52 "many link closers with no openers":
53 (("a]" * 65000),
54 - re.compile("(a\]){65000}")),
55 + re.compile("(a\\]){65000}")),
56 "many link openers with no closers":
57 (("[a" * 65000),
58 - re.compile("(\[a){65000}")),
59 + re.compile("(\\[a){65000}")),
60 "mismatched openers and closers":
61 (("*a_ " * 50000),
62 re.compile("([*]a[_] ){49999}[*]a_")),
63 @@ -60,19 +60,19 @@ pathological = {
64 re.compile("a[*][*]b(c[*] ){49999}c[*]")),
65 "link openers and emph closers":
66 (("[ a_" * 50000),
67 - re.compile("(\[ a_){50000}")),
68 + re.compile("(\\[ a_){50000}")),
69 "pattern [ (]( repeated":
70 (("[ (](" * 80000),
71 - re.compile("(\[ \(\]\(){80000}")),
72 + re.compile("(\\[ \\(\\]\\(){80000}")),
73 "pattern ![[]() repeated":
74 ("![[]()" * 160000,
75 - re.compile("(!\[<a href=\"\"></a>){160000}")),
76 + re.compile("(!\\[<a href=\"\"></a>){160000}")),
77 "hard link/emph case":
78 ("**x [a*b**c*](d)",
79 re.compile("\\*\\*x <a href=\"d\">a<em>b\\*\\*c</em></a>")),
80 "nested brackets":
81 (("[" * 50000) + "a" + ("]" * 50000),
82 - re.compile("\[{50000}a\]{50000}")),
83 + re.compile("\\[{50000}a\\]{50000}")),
84 "nested block quotes":
85 ((("> " * 50000) + "a"),
86 re.compile("(<blockquote>\n){50000}")),
87 @@ -87,13 +87,13 @@ pathological = {
88 re.compile("^<p>[e`]*</p>\n$")),
89 "unclosed links A":
90 ("[a](<b" * 30000,
91 - re.compile("(\[a\]\(&lt;b){30000}")),
92 + re.compile("(\\[a\\]\\(&lt;b){30000}")),
93 "unclosed links B":
94 ("[a](b" * 30000,
95 - re.compile("(\[a\]\(b){30000}")),
96 + re.compile("(\\[a\\]\\(b){30000}")),
97 "unclosed <!--":
98 ("</" + "<!--" * 300000,
99 - re.compile("\&lt;\/(\&lt;!--){300000}")),
100 + re.compile("\\&lt;\\/(\\&lt;!--){300000}")),
101 "tables":
102 ("aaa\rbbb\n-\v\n" * 30000,
103 re.compile("^<p>aaa</p>\n<table>\n<thead>\n<tr>\n<th>bbb</th>\n</tr>\n</thead>\n<tbody>\n(<tr>\n<td>aaa</td>\n</tr>\n<tr>\n<td>bbb</td>\n</tr>\n<tr>\n<td>-\x0b</td>\n</tr>\n){29999}</tbody>\n</table>\n$")),