# HG changeset patch # User neko259 # Date 2015-02-28 15:00:53 # Node ID 8af3de9ca7d852476c6815bdd4f5d558807b121a # Parent fb8126e759c031fad708b19dd7992107fd67a668 Don't turn emails into user casts diff --git a/boards/models/post.py b/boards/models/post.py --- a/boards/models/post.py +++ b/boards/models/post.py @@ -65,7 +65,7 @@ PREPARSE_PATTERNS = { r'>>(\d+)': r'[post]\1[/post]', # Reflink ">>123" r'^>([^>].+)': r'[quote]\1[/quote]', # Quote ">text" r'^//(.+)': r'[comment]\1[/comment]', # Comment "//text" - r'@(\w+)': r'[user]\1[/user]', # User notification "@user" + r'\B@(\w+)': r'[user]\1[/user]', # User notification "@user" } diff --git a/boards/tests/test_parser.py b/boards/tests/test_parser.py --- a/boards/tests/test_parser.py +++ b/boards/tests/test_parser.py @@ -25,3 +25,10 @@ class ParserTest(TestCase): self.assertEqual('[post]12[/post]\nText', preparsed_text, 'Reflink not preparsed.') + def preparse_user(self): + raw_text = '@user\nuser@example.com\n@user\nuser @user' + preparsed_text = Post.objects._preparse_text(raw_text) + + self.assertEqual('[user]user[/user]\nuser@example.com\n[user]user[/user]\nuser [user]user[/user]', + preparsed_text, 'User link not preparsed.') +