fenced_code: Optimize FENCE_RE to fix cubic worst-case complexity.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-05-13 10:42:53 -07:00
committed by Alex Vandiver
parent dea935f26f
commit 162e9d6c0b
4 changed files with 30 additions and 27 deletions

View File

@@ -167,7 +167,7 @@ def fix_spoilers_in_text(content: str, language: str) -> str:
m = FENCE_RE.match(line)
if m:
fence = m.group("fence")
lang = m.group("lang")
lang: Optional[str] = m.group("lang")
if lang == "spoiler":
open_fence = fence
output.append(line)