Ticket #10655: 10655-patch.diff

File 10655-patch.diff, 1.2 KB (added by floguy, 15 years ago)

Here's a patch for this problem

  • django/utils/text.py

     
    219219smart_split = allow_lazy(smart_split, unicode)
    220220
    221221def _replace_entity(match):
    222      text = match.group(1)
    223      if text[0] == u'#':
    224          text = text[1:]
    225          try:
    226              if text[0] in u'xX':
    227                  c = int(text[1:], 16)
    228              else:
    229                  c = int(text)
    230              return unichr(c)
    231          except ValueError:
    232              return match.group(0)
    233      else:
    234          try:
    235              return unichr(name2codepoint[text])
    236          except (ValueError, KeyError):
    237              return match.group(0)
     222    text = match.group(1)
     223    if text[0] == u'#':
     224        text = text[1:]
     225        try:
     226            if text[0] in u'xX':
     227                c = int(text[1:], 16)
     228            else:
     229                c = int(text)
     230            return unichr(c)
     231        except ValueError:
     232            return match.group(0)
     233    else:
     234        try:
     235            return unichr(name2codepoint[text])
     236        except (ValueError, KeyError):
     237            return match.group(0)
    238238
    239239_entity_re = re.compile(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));")
    240240
Back to Top