--- a/mercurial/templatefilters.py Sun Feb 24 17:58:55 2008 +0100
+++ b/mercurial/templatefilters.py Mon Jan 28 22:19:12 2008 -0500
@@ -121,6 +121,15 @@
return "-rwxr-xr-x"
return "-rw-r--r--"
+def xmlescape(text):
+ text = (text
+ .replace('&', '&')
+ .replace('<', '<')
+ .replace('>', '>')
+ .replace('"', '"')
+ .replace("'", ''')) # ' invalid in HTML
+ return re.sub('[\x00-\x08\x0B\x0C\x0E-\x1F]', ' ', text)
+
filters = {
"addbreaks": nl2br,
"basename": os.path.basename,
@@ -147,5 +156,6 @@
"urlescape": lambda x: urllib.quote(x),
"user": lambda x: util.shortuser(x),
"stringescape": lambda x: x.encode('string_escape'),
+ "xmlescape": xmlescape,
}