add "nofollow" and escape HTML input

This commit is contained in:
lars 2012-03-31 11:41:54 +00:00
parent 962c560ed0
commit 944b6b781c

View file

@ -295,8 +295,9 @@ def get_markup_with_links(text):
prefix, url, suffix = match.groups()
# only take the TLD part of the url
short_name = url.split("/")[2]
return """%s<a href="%s">%s</a>%s""" % (prefix, url, short_name, suffix)
return """%s<a href="%s" rel="nofollow">%s</a>%s""" % (prefix, url, short_name, suffix)
# surround all urls with html markup
text = genshi.escape(text)
text = re.sub(r"(\A|\s|\()(https?://[\w/\?\.\#=;,_\-\~&]*)(\)|\s|\Z)",
get_link_markup, text)
return get_markup_with_formatted_linebreaks(text, "<br />")