Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion htmlentities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def encode(source):


def decode(source):
for entitie in re.findall('&(?:[a-z][a-z0-9]+);', source):
for entitie in re.findall('&(?:[a-z][a-z0-9]+);', source, re.I):
entitie = entitie.replace('&', '')
entitie = entitie.replace(';', '')
source = source.replace('&%s;' % entitie, unichr(name2codepoint[entitie]))
Expand Down
10 changes: 10 additions & 0 deletions tests/test_decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ def test_should_decode_basic_entities(self):
def test_should_decode_utf8_accents(self):
self.assertEqual(u'é', htmlentities.decode('é'))
self.assertEqual(u'ê', htmlentities.decode('ê'))

def test_decode_complex_unicode_text(self):
"""Validates the encoding and decoding of sample text"""
text = u"Übergroße Äpfel mit Würmern"

# result string: Übergroße Äpfel mit Würmern

result = htmlentities.decode(htmlentities.encode(text))

self.assertEquals(result, text)