* open links in chats in new tabs * fixed target_blank vulnerability * add test to make sur links are being generated with target _blank * add test for target blank vulnerability * add rel and target to the whitelisted attributes * add the link attributes to HTMLRouge#link
20 lines
573 B
Ruby
20 lines
573 B
Ruby
require "rouge/plugins/redcarpet"
|
|
|
|
module Redcarpet
|
|
module Render
|
|
class HTMLRouge < HTML
|
|
include Rouge::Plugins::Redcarpet
|
|
|
|
def link(link, _title, content)
|
|
# Probably not the best fix but it does it's job of preventing
|
|
# a nested links.
|
|
return nil if /<a\s.+\/a>/.match?(content)
|
|
link_attributes = ""
|
|
@options[:link_attributes]&.each do |attribute, value|
|
|
link_attributes += %( #{attribute}="#{value}")
|
|
end
|
|
%(<a href="#{link}"#{link_attributes}>#{content}</a>)
|
|
end
|
|
end
|
|
end
|
|
end
|