Commit 331154ff authored by Douwe Maan's avatar Douwe Maan

Escape reference link text

parent e622259d
...@@ -110,13 +110,7 @@ module Banzai ...@@ -110,13 +110,7 @@ module Banzai
url = matches[:url] if matches.names.include?("url") url = matches[:url] if matches.names.include?("url")
url ||= url_for_object(object, project) url ||= url_for_object(object, project)
text = link_text text = link_text || escape_once(object_link_text(object, matches))
unless text
text = object.reference_link_text(context[:project])
extras = object_link_text_extras(object, matches)
text += " (#{extras.join(", ")})" if extras.any?
end
%(<a href="#{url}" #{data} %(<a href="#{url}" #{data}
title="#{title}" title="#{title}"
...@@ -140,6 +134,15 @@ module Banzai ...@@ -140,6 +134,15 @@ module Banzai
def object_link_title(object) def object_link_title(object)
"#{object_class.name.titleize}: #{object.title}" "#{object_class.name.titleize}: #{object.title}"
end end
def object_link_text(object, matches)
text = object.reference_link_text(context[:project])
extras = object_link_text_extras(object, matches)
text += " (#{extras.join(", ")})" if extras.any?
text
end
end end
end end
end end
...@@ -48,7 +48,7 @@ module Banzai ...@@ -48,7 +48,7 @@ module Banzai
end end
def escape_once(html) def escape_once(html)
ERB::Util.html_escape_once(html) html.html_safe? ? html : ERB::Util.html_escape_once(html)
end end
def ignore_parents def ignore_parents
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment