Просмотр исходного кода

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 лет назад
Родитель
Сommit
cbb88a3b6b
1 измененных файлов с 3 добавлено и 0 удалено
  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.utils import six
 
+from misago.conf import settings
+
 from .bbcode import blocks, inline
 from .md.shortimgs import ShortImagesExtension
 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):
     result['parsed_text'] = bleach.linkify(
         result['parsed_text'],
+        callbacks=getattr(settings, "MISAGO_BLEACH_CALLBACKS", []),
         skip_tags=['a', 'code', 'pre'],
         parse_email=True,
     )