Projet

Général

Profil

0001-trivial-update-to-use-html.unescape-48794.patch

Frédéric Péters, 24 novembre 2020 14:24

Télécharger (3,45 ko)

Voir les différences:

Subject: [PATCH] trivial: update to use html.unescape (#48794)

 wcs/fields.py      | 4 ++--
 wcs/qommon/form.py | 5 ++---
 wcs/qommon/misc.py | 4 ++--
 3 files changed, 6 insertions(+), 7 deletions(-)
wcs/fields.py
18 18

  
19 19
import copy
20 20
import datetime
21
import html
21 22
import os
22 23
import time
23 24
import random
......
34 35
from django.utils.encoding import force_bytes, force_text, smart_text
35 36
from django.utils.formats import date_format as django_date_format
36 37
from django.utils.html import urlize
37
from django.utils.six.moves.html_parser import HTMLParser
38 38

  
39 39
from .qommon import _, N_, force_str
40 40
from .qommon import evalutils
......
213 213

  
214 214
    @property
215 215
    def unhtmled_label(self):
216
        return force_str(HTMLParser().unescape(force_text(
216
        return force_str(html.unescape(force_text(
217 217
            re.sub('<.*?>', ' ', self.label))).strip())
218 218

  
219 219
    def get_admin_attributes(self):
wcs/qommon/form.py
18 18
import collections
19 19
import copy
20 20
import fnmatch
21
import html
21 22
import mimetypes
22 23
import os
23 24
import re
......
64 65

  
65 66
from django.utils.encoding import force_bytes, force_text
66 67
from django.utils import six
67
from django.utils.six.moves.html_parser import HTMLParser
68 68

  
69 69
from django.conf import settings
70 70
from django.utils.safestring import mark_safe
......
1718 1718
            if self.value.endswith('<br />'):
1719 1719
                self.value = self.value[:-6]
1720 1720
            # unescape Django template tags
1721
            parser = HTMLParser()
1722 1721
            charset = get_publisher().site_charset
1723 1722
            def unquote_django(matchobj):
1724
                return force_str(parser.unescape(force_text(matchobj.group(0), charset)))
1723
                return force_str(html.unescape(force_text(matchobj.group(0), charset)))
1725 1724
            self.value = re.sub('{[{%](.*?)[%}]}', unquote_django, self.value)
1726 1725
            if self.validation_function:
1727 1726
                try:
wcs/qommon/misc.py
17 17
import datetime
18 18
import decimal
19 19
import calendar
20
import html
20 21
import re
21 22
import os
22 23
import time
......
40 41
from django.utils.encoding import force_text
41 42
from django.utils.html import strip_tags
42 43
from django.template import TemplateSyntaxError, VariableDoesNotExist
43
from django.utils.six.moves.html_parser import HTMLParser
44 44
from django.utils.six.moves.urllib.parse import quote, urlencode
45 45
from django.utils.six.moves.urllib import parse as urlparse
46 46
from django.utils.text import Truncator
......
680 680
def html2text(text):
681 681
    if isinstance(text, (htmltext, str)):
682 682
        text = force_text(str(text), get_publisher().site_charset)
683
    return site_encode(HTMLParser().unescape(strip_tags(text)))
683
    return site_encode(html.unescape(strip_tags(text)))
684 684

  
685 685

  
686 686
def validate_luhn(string_value, length=None):
687
-