add "nofollow" and escape HTML input
This commit is contained in:
parent
962c560ed0
commit
944b6b781c
1 changed files with 2 additions and 1 deletions
|
@ -295,8 +295,9 @@ def get_markup_with_links(text):
|
||||||
prefix, url, suffix = match.groups()
|
prefix, url, suffix = match.groups()
|
||||||
# only take the TLD part of the url
|
# only take the TLD part of the url
|
||||||
short_name = url.split("/")[2]
|
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
|
# surround all urls with html markup
|
||||||
|
text = genshi.escape(text)
|
||||||
text = re.sub(r"(\A|\s|\()(https?://[\w/\?\.\#=;,_\-\~&]*)(\)|\s|\Z)",
|
text = re.sub(r"(\A|\s|\()(https?://[\w/\?\.\#=;,_\-\~&]*)(\)|\s|\Z)",
|
||||||
get_link_markup, text)
|
get_link_markup, text)
|
||||||
return get_markup_with_formatted_linebreaks(text, "<br />")
|
return get_markup_with_formatted_linebreaks(text, "<br />")
|
||||||
|
|
Loading…
Reference in a new issue