Only replace usernames when followed by a space to prevent replacing domains in emails that match usernames.

master
Nick Sergeant 2013-06-01 23:37:46 -04:00
parent 6546b8b673
commit 22c4699e7b
1 changed files with 2 additions and 2 deletions

View File

@ -77,14 +77,14 @@ class Snipt(models.Model):
self.stylized = self.stylized.replace('[[tweet-{}]]'.format(str(match)), '<div class="embedded-tweet" data-tweet-id="{}"></div>'.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)), '<a href="{}">@{}</a>'.format(url, match))
self.stylized = self.stylized.replace('@{} '.format(str(match)), '<a href="{}">@{}</a> '.format(url, match))
else:
self.stylized = highlight(self.code,