diff --git a/lib/diaspora/taggable.rb b/lib/diaspora/taggable.rb index fae6f177a..87ca36417 100644 --- a/lib/diaspora/taggable.rb +++ b/lib/diaspora/taggable.rb @@ -40,13 +40,14 @@ module Diaspora end def self.format_tags(text, opts={}) - return text if opts[:plain_text] + return text if opts[:plain_text] + text = ERB::Util.h(text) unless opts[:no_escape] regex = /(^|\s|>)#(#{VALID_TAG_BODY})/ - form_message = text.to_str.gsub(regex) do |matched_string| - "#{$~[1]}##{$~[2]}" - end - form_message.html_safe + + text.to_str.gsub(regex) { |matched_string| + %{#{$1}##{$2}} + }.html_safe end end end