Gregory Petukhov committed e070ff8

Drop hand-made urlize and use django default urlize

  • Participants
  • Parent commits 8a3fd84

Comments (0)

Files changed (3)

 from django.utils.html import strip_tags
 from django.utils.translation import ugettext_lazy as _
 from django.conf import settings
+from django.template.defaultfilters import urlize
 from pybb.markups import mypostmarkup
-from pybb.util import urlize, unescape
+from pybb.util import unescape
 from common.fields import JSONField
 from django.utils.translation import check_for_language
 from django import forms
-from django.template.defaultfilters import urlize as django_urlize
 from django.core.paginator import Paginator, EmptyPage, InvalidPage
 from django.conf import settings
 from django.contrib.sites.models import Site
-def urlize(data):
-    """
-    Urlize plain text links in the HTML contents.
-    Do not urlize content of A and CODE tags.
-    """
-    soup = BeautifulSoup(data)
-    for chunk in soup.findAll(text=True):
-        islink = False
-        ptr = chunk.parent
-        while ptr.parent:
-            if == 'a' or == 'code':
-                islink = True
-                break
-            ptr = ptr.parent
-        if not islink:
-            chunk = chunk.replaceWith(django_urlize(unicode(chunk)))
-    return unicode(soup)
 def quote_text(text, markup, username=""):
     Quote message using selected markup.
 from common.pagination import paginate
 from pybb.markups import mypostmarkup
-from pybb.util import quote_text, set_language, urlize
+from pybb.util import quote_text, set_language
 from pybb.models import Category, Forum, Topic, Post, Profile, \
                         Attachment, MARKUP_CHOICES
 from pybb.forms import  AddPostForm, EditPostForm, EditHeadPostForm, \