diff --git a/app/helpers/status_messages_helper.rb b/app/helpers/status_messages_helper.rb index 2dfbd31cccebfd08c4da3d55f9ba55c480fca28f..4131ccaf080f83322989ecba4316e1b92d8be600 100644 --- a/app/helpers/status_messages_helper.rb +++ b/app/helpers/status_messages_helper.rb @@ -10,4 +10,14 @@ module StatusMessagesHelper return I18n.t('status_messages.helper.no_message_to_display') end end + + def make_links(message) + # If there should be some kind of bb-style markup, email/diaspora highlighting, it could go here. + + # next line is important due to XSS! (h is rail's make_html_safe-function) + message = h(message).html_safe + message.gsub!(/( |^)(www\.[^ ]+\.[^ ])/, '\1http://\2'); + return message.gsub(/(http|ftp):\/\/([^ ]+)/, '<a target="_blank" href="\1://\2">\2</a>'); + end + end diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index 8a7b6cbba2f028f537262a0dae447e1ebf19cf49..8b2437ae9fc9e8beacd3a3da7a6deae5ad366ec7 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -23,7 +23,7 @@ = render "shared/reshare", :post => post, :current_user => current_user = link_to t('.delete'), status_message_path(post), :confirm => t('.are_you_sure'), :method => :delete, :remote => true, :class => "delete" - = post.message + = make_links(post.message) .info %span.time= link_to(how_long_ago(post), object_path(post))