Issue 3905: Usernames with dashes in them can't be @mentioned.
parent
318995d7a7
commit
2c7de59ff8
|
@ -32,7 +32,7 @@ from taiga.users.models import User
|
||||||
|
|
||||||
class MentionsExtension(Extension):
|
class MentionsExtension(Extension):
|
||||||
def extendMarkdown(self, md, md_globals):
|
def extendMarkdown(self, md, md_globals):
|
||||||
MENTION_RE = r'(@)([a-zA-Z0-9.-\.]+)'
|
MENTION_RE = r'(@)([a-zA-Z0-9.-\._]+)'
|
||||||
mentionsPattern = MentionsPattern(MENTION_RE)
|
mentionsPattern = MentionsPattern(MENTION_RE)
|
||||||
mentionsPattern.md = md
|
mentionsPattern.md = md
|
||||||
md.inlinePatterns.add('mentions', mentionsPattern, '_end')
|
md.inlinePatterns.add('mentions', mentionsPattern, '_end')
|
||||||
|
|
|
@ -38,6 +38,13 @@ def test_proccessor_valid_user_mention():
|
||||||
assert result == expected_result
|
assert result == expected_result
|
||||||
|
|
||||||
|
|
||||||
|
def test_proccessor_valid_user_mention_with_dashes():
|
||||||
|
factories.UserFactory(username="user1_text_after_dash", full_name="test name")
|
||||||
|
result = render(dummy_project, "**@user1_text_after_dash**")
|
||||||
|
expected_result = "<p><strong><a class=\"mention\" href=\"http://localhost:9001/profile/user1_text_after_dash\" title=\"test name\">@user1_text_after_dash</a></strong></p>"
|
||||||
|
assert result == expected_result
|
||||||
|
|
||||||
|
|
||||||
def test_proccessor_invalid_user_mention():
|
def test_proccessor_invalid_user_mention():
|
||||||
result = render(dummy_project, "**@notvaliduser**")
|
result = render(dummy_project, "**@notvaliduser**")
|
||||||
assert result == '<p><strong>@notvaliduser</strong></p>'
|
assert result == '<p><strong>@notvaliduser</strong></p>'
|
||||||
|
|
Loading…
Reference in New Issue