From 22c4699e7b133c6e092081fff1b4e65837a20190 Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Sat, 1 Jun 2013 23:37:46 -0400 Subject: [PATCH] Only replace usernames when followed by a space to prevent replacing domains in emails that match usernames. --- snipts/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snipts/models.py b/snipts/models.py index b4a757c..1dbefc5 100644 --- a/snipts/models.py +++ b/snipts/models.py @@ -77,14 +77,14 @@ class Snipt(models.Model): self.stylized = self.stylized.replace('[[tweet-{}]]'.format(str(match)), '
'.format(str(match))) # Parse Snipt usernames - for match in re.findall('@(\w+)', self.stylized): + for match in re.findall('@(\w+) ', self.stylized): # Try and get the Snipt user by username. user = get_object_or_None(User, username=match) if user: url = user.profile.get_user_profile_url() - self.stylized = self.stylized.replace('@{}'.format(str(match)), '@{}'.format(url, match)) + self.stylized = self.stylized.replace('@{} '.format(str(match)), '@{} '.format(url, match)) else: self.stylized = highlight(self.code,