From d47059d246170182e3203e9e665b7e93e4241196 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Wed, 7 Sep 2016 16:08:55 -0700 Subject: [PATCH] fixes #2654: @mentions shouldn't link to Danbooru users in artist commentaries --- app/logical/d_text.rb | 6 ++++-- app/views/artist_commentaries/_show.html.erb | 6 +++--- app/views/artists/show.html.erb | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/logical/d_text.rb b/app/logical/d_text.rb index ec165638e..c5242d5c6 100644 --- a/app/logical/d_text.rb +++ b/app/logical/d_text.rb @@ -45,7 +45,7 @@ class DText str.gsub!(/\[u\](.+?)\[\/u\]/i, '\1') str.gsub!(/\[tn\](.+?)\[\/tn\]/i, '

\1

') - str = parse_mentions(str) + str = parse_mentions(str, options) str = parse_links(str) str = parse_aliased_wiki_links(str) str = parse_wiki_links(str) @@ -54,7 +54,9 @@ class DText str end - def self.parse_mentions(str) + def self.parse_mentions(str, options = {}) + return if options[:disable_mentions] + str.gsub!(MENTION_REGEXP) do |name| next name unless name =~ /[a-z0-9]/i diff --git a/app/views/artist_commentaries/_show.html.erb b/app/views/artist_commentaries/_show.html.erb index 7be442828..7ef57bdcd 100644 --- a/app/views/artist_commentaries/_show.html.erb +++ b/app/views/artist_commentaries/_show.html.erb @@ -15,7 +15,7 @@

<%= artist_commentary.original_title %>

- <%= format_text(artist_commentary.original_description, :ragel => true) %> + <%= format_text(artist_commentary.original_description, :ragel => true, :disable_mentions => true) %>
<% end %> @@ -31,9 +31,9 @@
<% if artist_commentary.translated_description.present? %> - <%= format_text(artist_commentary.translated_description, :ragel => true) %> + <%= format_text(artist_commentary.translated_description, :ragel => true, :disable_mentions => true) %> <% else %> - <%= format_text(artist_commentary.original_description, :ragel => true) %> + <%= format_text(artist_commentary.original_description, :ragel => true, :disable_mentions => true) %> <% end %>
diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index 05f1facce..518c81256 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -4,7 +4,7 @@ <% if @artist.notes.present? && @artist.visible? %>
- <%= format_text(@artist.notes, :ragel => true) %> + <%= format_text(@artist.notes, :ragel => true, :disable_mentions => true) %>

<%= link_to "View wiki page", @artist.wiki_page %>