Merge pull request #604 from mouse-reeve/link-format-bug

Link format bug
This commit is contained in:
Mouse Reeve 2021-02-10 12:45:04 -08:00 committed by GitHub
commit 222dc118af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -217,6 +217,16 @@ class StatusViews(TestCase):
'is rad</p>')
def test_to_markdown_link(self):
''' this is mostly handled in other places, but nonetheless '''
text = '[hi](http://fish.com) is <marquee>rad</marquee>'
result = views.status.to_markdown(text)
self.assertEqual(
result,
'<p><a href="http://fish.com">hi</a> ' \
'is rad</p>')
def test_handle_delete_status(self):
''' marks a status as deleted '''
view = views.DeleteStatus.as_view()

View file

@ -48,7 +48,6 @@ class CreateStatus(View):
r'<a href="%s">%s</a>\g<1>' % \
(mention_user.remote_id, mention_text),
content)
# add reply parent to mentions and notify
if status.reply_parent:
status.mention_users.add(status.reply_parent.user)
@ -126,8 +125,8 @@ def format_links(content):
def to_markdown(content):
''' catch links and convert to markdown '''
content = format_links(content)
content = markdown(content)
content = format_links(content)
# sanitize resulting html
sanitizer = InputHtmlParser()
sanitizer.feed(content)