Loading django/utils/text.py +2 −2 Original line number Diff line number Diff line Loading @@ -381,12 +381,12 @@ def _replace_entity(match): c = int(text[1:], 16) else: c = int(text) return unichr(c) return six.unichr(c) except ValueError: return match.group(0) else: try: return unichr(html_entities.name2codepoint[text]) return six.unichr(html_entities.name2codepoint[text]) except (ValueError, KeyError): return match.group(0) Loading tests/regressiontests/utils/text.py +13 −0 Original line number Diff line number Diff line Loading @@ -121,3 +121,16 @@ class TestUtilsText(SimpleTestCase): ) for value, output in items: self.assertEqual(text.slugify(value), output) def test_unescape_entities(self): items = [ ('', ''), ('foo', 'foo'), ('&', '&'), ('&', '&'), ('&', '&'), ('foo & bar', 'foo & bar'), ('foo & bar', 'foo & bar'), ] for value, output in items: self.assertEqual(text.unescape_entities(value), output) Loading
django/utils/text.py +2 −2 Original line number Diff line number Diff line Loading @@ -381,12 +381,12 @@ def _replace_entity(match): c = int(text[1:], 16) else: c = int(text) return unichr(c) return six.unichr(c) except ValueError: return match.group(0) else: try: return unichr(html_entities.name2codepoint[text]) return six.unichr(html_entities.name2codepoint[text]) except (ValueError, KeyError): return match.group(0) Loading
tests/regressiontests/utils/text.py +13 −0 Original line number Diff line number Diff line Loading @@ -121,3 +121,16 @@ class TestUtilsText(SimpleTestCase): ) for value, output in items: self.assertEqual(text.slugify(value), output) def test_unescape_entities(self): items = [ ('', ''), ('foo', 'foo'), ('&', '&'), ('&', '&'), ('&', '&'), ('foo & bar', 'foo & bar'), ('foo & bar', 'foo & bar'), ] for value, output in items: self.assertEqual(text.unescape_entities(value), output)