comparison mercurial/templater.py @ 2643:3b53fa20dda8

Preserve multibyte UTF-8 characters when obfuscating. This version uses the unicode 'replace' option, so non-UTF-8 encodings will still be mangled. Luckily, there aren't any of those.
author Brendan Cully <brendan@kublai.com>
date Fri, 21 Jul 2006 02:36:17 +0200
parents bf67d0f6531c
children 3d6efcbbd1c9
comparison
equal deleted inserted replaced
2642:f47432ae5376 2643:3b53fa20dda8
239 def nl2br(text): 239 def nl2br(text):
240 '''replace raw newlines with xhtml line breaks.''' 240 '''replace raw newlines with xhtml line breaks.'''
241 return text.replace('\n', '<br/>\n') 241 return text.replace('\n', '<br/>\n')
242 242
243 def obfuscate(text): 243 def obfuscate(text):
244 text = unicode(text, 'utf-8', 'replace')
244 return ''.join(['&#%d;' % ord(c) for c in text]) 245 return ''.join(['&#%d;' % ord(c) for c in text])
245 246
246 def domain(author): 247 def domain(author):
247 '''get domain of author, or empty string if none.''' 248 '''get domain of author, or empty string if none.'''
248 f = author.find('@') 249 f = author.find('@')