From f430ee323a61483a07120f259d89b5110b340345 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 21 2017 12:48:23 +0000 Subject: Fix running the tests against bleach 1.5.0 --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 4e15f14..de7a061 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -3382,7 +3382,24 @@ def clean_input(text, ignore=None): if tag in tags: tags.remove(tag) - return bleach.clean(text, tags=tags, attributes=attrs) + args = { + 'tags': tags, + 'attributes': attrs + } + + # newer bleach allow to customize the protocol supported + bleach_v = bleach.__version__.split('.') + for idx, val in enumerate(bleach_v): + try: + val = int(val) + except ValueError: + pass + bleach_v[idx] = val + if tuple(bleach_v) >= (1, 5, 0): + protocols=bleach.ALLOWED_PROTOCOLS + ['irc', 'ircs'] + args['protocols'] = protocols + + return bleach.clean(text, **args) def could_be_text(text): diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py index 7c864f0..c0b307d 100644 --- a/tests/test_pagure_lib.py +++ b/tests/test_pagure_lib.py @@ -3333,6 +3333,16 @@ class PagureLibtests(tests.Modeltests): self.assertEqual(iss.id, 8) self.assertEqual(iss.title, 'private issue #8') + # newer bleach allow to customize the protocol supported + import bleach + bleach_v = bleach.__version__.split('.') + for idx, val in enumerate(bleach_v): + try: + val = int(val) + except ValueError: + pass + bleach_v[idx] = val + texts = [ 'foo bar test#1 see?', 'foo bar pingou/test#2 I mean, really', @@ -3394,7 +3404,9 @@ class PagureLibtests(tests.Modeltests): # and the version 1.4.3 that we have won't let us adjust the # list of supported protocols # '

ircs://pagure.io

', - '

ircs://pagure.io

', + '

ircs://pagure.io

' if + tuple(bleach_v) >= (1, 5, 0) + else '

ircs://pagure.io

', # 'http://pagure.io' '

http://pagure.io

', # 'https://pagure.io'