Skip to content

Commit 331bbbf

Browse files
committed
Fix for incorrect [\s\S] matching by re module
1 parent 9bb2220 commit 331bbbf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adafruit_templateengine.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,11 @@ def safe_markdown(value: Any) -> str:
156156
_PRECOMPILED_BLOCK_PATTERN = re.compile(r"{% block \w+? %}")
157157
_PRECOMPILED_INCLUDE_PATTERN = re.compile(r"{% include '.+?' %}|{% include \".+?\" %}")
158158
_PRECOMPILED_HASH_COMMENT_PATTERN = re.compile(r"{# .+? #}")
159+
# Workaround for bug in re module https://github.com/adafruit/circuitpython/issues/8525
159160
_PRECOMPILED_BLOCK_COMMENT_PATTERN = re.compile(
160-
r"{% comment ('.*?' |\".*?\" )?%}[\s\S]*?{% endcomment %}"
161+
# TODO: Use r"{% comment ('.*?' |\".*?\" )?%}[\s\S]*?{% endcomment %}" without flags when fixed
162+
r"{% comment ('.*?' |\".*?\" )?%}.*?{% endcomment %}",
163+
16, # re.DOTALL flag
161164
)
162165
_PRECOMPILED_TOKEN_PATTERN = re.compile(r"{{ .+? }}|{% .+? %}")
163166

0 commit comments

Comments
 (0)