Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
fix html_enteties ValueError #84
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Demah committed May 3, 2015
1 parent 88bb1c6 commit 3c663b9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions django_th/html_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def html_entity_decode_char(self, m, defs=htmlentities.entitydefs):
decode html entity into one of the html char
"""
try:
return "&" + defs[m.group(1)] + ";"
char = defs[m.group(1)] + ";"
return "&{char};".format(char=char)
except KeyError:
return m.group(0)

Expand All @@ -28,7 +29,8 @@ def html_entity_decode_codepoint(self, m,
decode html entity into one of the codepoint2name
"""
try:
return "&" + defs[int(m.group(1))] + ";"
char = defs[m.group(1)] + ";"
return "&{char};".format(char=char)
except KeyError:
return m.group(0)

Expand Down

0 comments on commit 3c663b9

Please sign in to comment.