mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-07 18:58:30 +02:00
Linkify plain URLs in notes (#1051)
* Linkify plain URLs in notes * add test case --------- Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@gmail.com>
This commit is contained in:
@@ -142,5 +142,6 @@ def render_markdown(context, markdown_text):
|
||||
|
||||
as_html = renderer.convert(markdown_text)
|
||||
sanitized_html = bleach.clean(as_html, markdown_tags, markdown_attrs)
|
||||
linkified_html = bleach.linkify(sanitized_html)
|
||||
|
||||
return mark_safe(sanitized_html)
|
||||
return mark_safe(linkified_html)
|
||||
|
@@ -884,6 +884,21 @@ class BookmarkListTemplateTest(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
||||
)
|
||||
self.assertNotes(html, note_html, 1)
|
||||
|
||||
def test_note_renders_markdown_with_linkify(self):
|
||||
# Should linkify plain URL
|
||||
self.setup_bookmark(notes="Example: https://example.com")
|
||||
html = self.render_template()
|
||||
|
||||
note_html = '<p>Example: <a href="https://example.com" rel="nofollow">https://example.com</a></p>'
|
||||
self.assertNotes(html, note_html, 1)
|
||||
|
||||
# Should not linkify URL in markdown link
|
||||
self.setup_bookmark(notes="[https://example.com](https://example.com)")
|
||||
html = self.render_template()
|
||||
|
||||
note_html = '<p><a href="https://example.com" rel="nofollow">https://example.com</a></p>'
|
||||
self.assertNotes(html, note_html, 1)
|
||||
|
||||
def test_note_cleans_html(self):
|
||||
self.setup_bookmark(notes='<script>alert("test")</script>')
|
||||
self.setup_bookmark(
|
||||
|
Reference in New Issue
Block a user