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

bump django to 1.11 and other deps to current

Rafał Pitoń 8 лет назад
Родитель
Сommit
42d1837baa

+ 6 - 12
misago/markup/parser.py

@@ -144,18 +144,11 @@ def md_factory(allow_links=True, allow_images=True, allow_blocks=True):
 
 
 def linkify_paragraphs(result):
-    result['parsed_text'] = bleach.linkify(result['parsed_text'], skip_pre=True, parse_email=True)
-
-    # dirty fix for
-    if '<code>' in result['parsed_text'] and '<a' in result['parsed_text']:
-        with warnings.catch_warnings():
-            warnings.simplefilter("ignore")
-
-            soup = BeautifulSoup(result['parsed_text'], 'html5lib')
-            for link in soup.select('code > a'):
-                link.replace_with(BeautifulSoup(link.string, 'html.parser'))
-            # [6:-7] trims <body></body> wrap
-            result['parsed_text'] = six.text_type(soup.body)[6:-7]
+    result['parsed_text'] = bleach.linkify(
+        result['parsed_text'],
+        skip_tags=['a', 'code', 'pre'],
+        parse_email=True,
+    )
 
 
 def clean_links(request, result, force_shva=False):
@@ -170,6 +163,7 @@ def clean_links(request, result, force_shva=False):
         else:
             result['outgoing_links'].append(clean_link_prefix(link['href']))
             link['href'] = assert_link_prefix(link['href'])
+            link['rel'] = 'nofollow'
 
         if link.string:
             link.string = clean_link_prefix(link.string)

+ 1 - 1
misago/markup/tests/test_parser.py

@@ -286,7 +286,7 @@ Lorem ipsum: http://somewhere.com/somewhere-something/
         """.strip()
 
         expected_result = """
-<p><a href="/a/test/43/" rel="nofollow"><img alt="3.png" src="/a/thumb/test/43/"/></a></p>
+<p><a href="/a/test/43/"><img alt="3.png" src="/a/thumb/test/43/"/></a></p>
 """.strip()
 
         result = parse(test_text, MockRequest(), MockPoster(), minify=True)

+ 3 - 0
misago/threads/forms.py

@@ -95,5 +95,8 @@ class AttachmentTypeForm(forms.ModelForm):
         return self.clean_list(self.cleaned_data['mimetypes'])
 
     def clean_list(self, value):
+        if not value:
+            return None
+
         items = [v.lstrip('.') for v in value.lower().replace(' ', '').split(',')]
         return ','.join(set(filter(bool, items)))

+ 1 - 1
misago/users/authbackends.py

@@ -6,7 +6,7 @@ UserModel = get_user_model()
 
 
 class MisagoBackend(ModelBackend):
-    def authenticate(self, username=None, password=None, **kwargs):
+    def authenticate(self, request, username=None, password=None, **kwargs):
         if username is None:
             username = kwargs.get(UserModel.USERNAME_FIELD)
 

+ 5 - 0
misago/users/tests/test_auth_backend.py

@@ -17,6 +17,7 @@ class MisagoBackendTests(TestCase):
     def test_authenticate_username(self):
         """auth authenticates with username"""
         user = backend.authenticate(
+            None,
             username=self.user.username,
             password=self.password,
         )
@@ -26,6 +27,7 @@ class MisagoBackendTests(TestCase):
     def test_authenticate_email(self):
         """auth authenticates with email instead of username"""
         user = backend.authenticate(
+            None,
             username=self.user.email,
             password=self.password,
         )
@@ -35,6 +37,7 @@ class MisagoBackendTests(TestCase):
     def test_authenticate_invalid_credential(self):
         """auth handles invalid credentials"""
         user = backend.authenticate(
+            None,
             username='InvalidCredential',
             password=self.password,
         )
@@ -44,6 +47,7 @@ class MisagoBackendTests(TestCase):
     def test_authenticate_invalid_password(self):
         """auth validates password"""
         user = backend.authenticate(
+            None,
             username=self.user.email,
             password='Invalid',
         )
@@ -56,6 +60,7 @@ class MisagoBackendTests(TestCase):
         self.user.save()
 
         user = backend.authenticate(
+            None,
             username=self.user.email,
             password=self.password,
         )

+ 13 - 13
requirements.txt

@@ -1,17 +1,17 @@
-django~=1.10.3
-djangorestframework~=3.5.3
-beautifulsoup4~=4.5.1
-bleach~=1.5.0
-django-debug-toolbar~=1.6
+django~=1.11.1
+djangorestframework~=3.6.3
+beautifulsoup4~=4.6.0
+bleach~=2.0.0
+django-debug-toolbar~=1.8
 django-crispy-forms~=1.6.1
 django-htmlmin~=0.10.0
-django-mptt~=0.8.6
-fake-factory~=0.7.2
-html5lib<0.99999999,>=0.999
-markdown~=2.6.7
-path.py~=9.0
-pillow~=4.0.0
-psycopg2~=2.6.2
+django-mptt~=0.8.7
+fake-factory
+html5lib==0.999999999
+markdown~=2.6.8
+path.py~=10.3.1
+pillow~=4.1.1
+psycopg2~=2.7.1
 pytz
 requests<3
-unidecode
+unidecode~=0.4.20

+ 0 - 2
runtests.py

@@ -4,7 +4,6 @@ import shutil
 import sys
 
 from django import setup
-from django.test.utils import setup_test_environment
 
 
 def runtests():
@@ -135,7 +134,6 @@ DATABASES = {
 
 def run_django(*args, **kwargs):
     setup()
-    setup_test_environment()
 
     from django.core.management import call_command
     sys.exit(call_command('test', *args, **kwargs))