FIX: Allow link redirects inside oneboxed posts

This commit is contained in:
Robin Ward
2013-11-29 14:29:28 -05:00
parent 298b54c0e7
commit 769223014c
2 changed files with 7 additions and 4 deletions

View File

@@ -22,7 +22,11 @@ class TopicLinkClick < ActiveRecord::Base
# If no link is found, return the url for relative links
unless link.present?
return args[:url] if args[:url] =~ /^\//
return nil
# If we have it somewhere else on the site, just allow the redirect. This is
# likely due to a onebox of another topic.
link = TopicLink.where(url: args[:url]).first
return link.present? ? link.url : nil
end
return args[:url] if (args[:user_id] && (link.user_id == args[:user_id]))