From 9cc79d9fa5ac05a8721e71d3466fd6b411b3bc7a Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 17 Jan 2022 18:15:23 +0000 Subject: [PATCH] Fix mention linkifying emails --- app/markdown.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/markdown.py b/app/markdown.py index b240b995..0eb1f49f 100644 --- a/app/markdown.py +++ b/app/markdown.py @@ -98,6 +98,8 @@ class MentionPattern(Pattern): self.config = config def handleMatch(self, m): + from app.models import User + label = m.group(2) user = m.group(3) package_name = m.group(4) @@ -107,6 +109,9 @@ class MentionPattern(Pattern): el.set("href", url_for("packages.view", author=user, name=package_name)) return el else: + if User.query.filter_by(username=user).count() == 0: + return None + el = ElementTree.Element("a") el.text = label el.set("href", url_for("users.profile", username=user))