From 9b00b87cf2b8a02fdb2595cd0e9bd37d1f7ab32e Mon Sep 17 00:00:00 2001 From: Justin Bronn Date: Mon, 30 Mar 2009 03:03:37 +0000 Subject: [PATCH] Fixed #10655 -- Who uses 5-space indentation anyways? Thanks to Andrew Badr for the ticket & patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10186 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/text.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/django/utils/text.py b/django/utils/text.py index c90065265a..147fab4038 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -219,27 +219,27 @@ def smart_split(text): smart_split = allow_lazy(smart_split, unicode) def _replace_entity(match): - text = match.group(1) - if text[0] == u'#': - text = text[1:] - try: - if text[0] in u'xX': - c = int(text[1:], 16) - else: - c = int(text) - return unichr(c) - except ValueError: - return match.group(0) - else: - try: - return unichr(name2codepoint[text]) - except (ValueError, KeyError): - return match.group(0) + text = match.group(1) + if text[0] == u'#': + text = text[1:] + try: + if text[0] in u'xX': + c = int(text[1:], 16) + else: + c = int(text) + return unichr(c) + except ValueError: + return match.group(0) + else: + try: + return unichr(name2codepoint[text]) + except (ValueError, KeyError): + return match.group(0) _entity_re = re.compile(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));") def unescape_entities(text): - return _entity_re.sub(_replace_entity, text) + return _entity_re.sub(_replace_entity, text) unescape_entities = allow_lazy(unescape_entities, unicode) def unescape_string_literal(s): @@ -261,4 +261,3 @@ def unescape_string_literal(s): quote = s[0] return s[1:-1].replace(r'\%s' % quote, quote).replace(r'\\', '\\') unescape_string_literal = allow_lazy(unescape_string_literal) -