Browse Source

Update parser.py

Add `MISAGO_BLEACH_CALLBACKS` setting to customize linkify behavior, as well as removing rel=nofollow from callbacks, because this add in clean_links (and only for external links).
musindmitriy 7 years ago
parent
commit
cbb88a3b6b
1 changed files with 3 additions and 0 deletions
  1. 3 0
      misago/markup/parser.py

+ 3 - 0
misago/markup/parser.py

@@ -12,6 +12,8 @@ from django.http import Http404
 from django.urls import resolve
 from django.urls import resolve
 from django.utils import six
 from django.utils import six
 
 
+from misago.conf import settings
+
 from .bbcode import blocks, inline
 from .bbcode import blocks, inline
 from .md.shortimgs import ShortImagesExtension
 from .md.shortimgs import ShortImagesExtension
 from .md.striketrough import StriketroughExtension
 from .md.striketrough import StriketroughExtension
@@ -152,6 +154,7 @@ def md_factory(allow_links=True, allow_images=True, allow_blocks=True):
 def linkify_paragraphs(result):
 def linkify_paragraphs(result):
     result['parsed_text'] = bleach.linkify(
     result['parsed_text'] = bleach.linkify(
         result['parsed_text'],
         result['parsed_text'],
+        callbacks=getattr(settings, "MISAGO_BLEACH_CALLBACKS", []),
         skip_tags=['a', 'code', 'pre'],
         skip_tags=['a', 'code', 'pre'],
         parse_email=True,
         parse_email=True,
     )
     )