Mercurial > kallithea
diff rhodecode/lib/helpers.py @ 2466:7010dc12f10c codereview
Added rewritten validators module + tests
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 17 Jun 2012 21:31:31 +0200 |
parents | 4753a3445ff7 |
children | 9fad28af93bd |
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py Sun Jun 17 21:30:26 2012 +0200 +++ b/rhodecode/lib/helpers.py Sun Jun 17 21:31:31 2012 +0200 @@ -51,6 +51,20 @@ log = logging.getLogger(__name__) +html_escape_table = { + "&": "&", + '"': """, + "'": "'", + ">": ">", + "<": "<", +} + + +def html_escape(text): + """Produce entities within text.""" + return "".join(html_escape_table.get(c,c) for c in text) + + def shorter(text, size=20): postfix = '...' if len(text) > size: