Projet

Général

Profil

0001-fields-fix-unhtmled_label-to-return-a-byte-string-10.patch

Frédéric Péters, 04 mars 2016 11:34

Télécharger (1,38 ko)

Voir les différences:

Subject: [PATCH] fields: fix unhtmled_label to return a byte string (#10193)

 tests/test_fields.py | 2 +-
 wcs/fields.py        | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
tests/test_fields.py
144 144
    assert field.unhtmled_label == 'Foobar'
145 145

  
146 146
    field = fields.CommentField(label='<p>Foobar&eacute;</p>')
147
    assert field.unhtmled_label == u'Foobaré'
147
    assert field.unhtmled_label == 'Foobaré'
148 148

  
149 149
def test_map():
150 150
    assert fields.MapField().get_json_value('42.2;10.2') == {'lat': 42.2, 'lon': 10.2}
wcs/fields.py
158 158

  
159 159
    @property
160 160
    def unhtmled_label(self):
161
        charset = get_publisher().site_charset
161 162
        return HTMLParser().unescape(unicode(
162
            re.sub('<.*?>', ' ', self.label), get_publisher().site_charset)).strip()
163
            re.sub('<.*?>', ' ', self.label), charset)).strip().encode(charset)
163 164

  
164 165
    def get_admin_attributes(self):
165 166
        return ['label', 'type']
166
-