fix(formatter): fixed runaway regex on templates with many template attriutes inside html tags

closes #340
This commit is contained in:
Christopher Pickering 2022-08-22 11:59:19 -05:00
parent 90cf5764ac
commit 79cd013f8d
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 5 additions and 5 deletions

View file

@ -61,13 +61,13 @@ def expand_html(html: str, config: Config) -> str:
if inside_ignored_block(config, html, match):
return match.group(1)
if not re.findall(
r"\<(?:"
+ str(config.indent_html_tags)
+ r")\b(?:[^>]|{%[^(?:%}]*?%}|{{[^(?:}}]*?}})*?"
+ re.escape(match.group(1))
+ "$",
+ r")\b(?:\"[^\"]*\"|'[^']*'|{{[^}]*}}|{%[^%]*%}|{\#[^\#]*\#}|[^>{}])*?"
# original
# + r")\b(?:[^>]|{%[^(?:%}]*?%}|{{[^(?:}}]*?}})*?"
+ re.escape(match.group(1)) + "$",
html[: match.end()],
re.MULTILINE | re.VERBOSE,
):

View file

@ -185,7 +185,7 @@
message: Tag seems to be an orphan.
flags: re.I|re.DOTALL
patterns:
- <((/?(\w+))\b(\"[^\"]*\"|'[^']*'|{{[^}]*}}|{%[^%]*%}|{#[^%]*#}|[^'\">{}])*)(?<!/)>
- <((/?(\w+))\b(\"[^\"]*\"|'[^']*'|{{[^}]*}}|{%[^%]*%}|{#[^#]*#}|[^'\">{}])*)(?<!/)>
- rule:
name: H026
message: Empty id and class tags can be removed.