misc: remove DeprecationWarning unescape (#39438)

DeprecationWarning: The unescape method is deprecated
and will be removed in 3.5, use html.unescape() instead.
This commit is contained in:
Lauréline Guérin 2020-01-31 11:47:07 +01:00
parent f2807ce2ec
commit 11882c5810
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 5 additions and 4 deletions

View File

@ -18,6 +18,7 @@ import collections
import copy
import feedparser
import hashlib
import html
import json
import logging
import os
@ -754,8 +755,7 @@ class CellBase(six.with_metaclass(CellMeta, models.Model)):
}
if not self.is_relevant(context):
return ''
from django.utils.six.moves.html_parser import HTMLParser
return HTMLParser().unescape(strip_tags(self.render(context)))
return html.unescape(strip_tags(self.render(context)))
def get_external_links_data(self):
return []

View File

@ -14,7 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.utils.six.moves.html_parser import HTMLParser
import html
from django.utils.six.moves.urllib import parse as urlparse
from django.conf import settings
@ -23,7 +24,7 @@ from django.utils.html import strip_tags
def ellipsize(text, length=50):
text = HTMLParser().unescape(strip_tags(text))
text = html.unescape(strip_tags(text))
if len(text) < length:
return text
return text[:(length-10)] + '...'