diff --git a/r2/r2/lib/filters.py b/r2/r2/lib/filters.py
index 257ffd6c1..fa6cf07d0 100644
--- a/r2/r2/lib/filters.py
+++ b/r2/r2/lib/filters.py
@@ -96,6 +96,7 @@ r_url = re.compile('(?', re.I | re.S)
href_re = re.compile('([^<]+)')
+a_re = re.compile('>([^<]+)')
#TODO markdown should be looked up in batch?
@@ -122,9 +123,14 @@ def safemarkdown(text):
def code_handler(m):
l = m.group(1)
return '%s' % l.replace('&','&')
+ #unescape double escaping in links
+ def inner_a_handler(m):
+ l = m.group(1)
+ return '>%s' % l.replace('&','&')
# remove the "&" escaping in urls
text = href_re.sub(href_handler, text)
text = code_re.sub(code_handler, text)
+ text = a_re.sub(inner_a_handler, text)
return MD_START + text + MD_END